Questions tagged [vimrc]

Vim reads initialization commands from a file called vimrc on startup. This can be used to set settings, define functions, execute autocommands, and more.

Filter by
Sorted by
Tagged with
105 votes
8 answers
29k views

How do I debug my vimrc file?

I have a problem in Vim, and I think it may be in my vimrc file (or have been told it could be my vimrc file). How do I verify this? If it is my vimrc file, how do I know where exactly the problem ...
user avatar
102 votes
2 answers
77k views

What is the purpose of swap files?

When I edit files, Vim tends to create files named .filename.swp, which I find annoying. From vim -h, I see that the -n option suppresses the creation of swap files. Is there a vimrc directive that ...
user avatar
  • 8,819
95 votes
5 answers
86k views

How to share config between vim and Neovim

I started using neovim and moved my .vimrc to .config/nvim/init.vim and other stuff is located in .local/share/nvim. What is the best way to share configs or even plugins between vim and Neovim? ...
user avatar
  • 1,199
71 votes
8 answers
51k views

Fastest way to switch to a buffer in vim?

One way to select a buffer in vim could be to browse the buffers list, using standard commands as :ls, or with some external plugin / vimscript code to browse a list in a window. Let's say I want to ...
user avatar
58 votes
3 answers
9k views

How do I reload my vimrc without leaving Vim?

When I do a change in my .vimrc, I usually exit Vim and open it again. Is there an easier way to reload the new .vimrc changes?
user avatar
  • 15.7k
42 votes
1 answer
24k views

Why do I need both a vimrc and a gvimrc?

There seems to be two ways to store preferences specific to gvim: Keep an .vimrc file for vim and a .gvimrc file for gvim specific additions. Keep all settings in .vimrc and wrap gvim specific ...
user avatar
  • 2,135
40 votes
6 answers
4k views

Applying settings to a directory tree only

At my work we use a standard ts of 2; my personal preference is 4, which is what I use for my hobby projects, and this other project we inherited has the convention of ts=8. There are also some other ...
user avatar
39 votes
2 answers
12k views

What's the difference between let and set?

I don't know much of the theory behind Vim. It looks as if we set some variables, and let other variables. What's the difference, and when is one required over the other? Also, the solarized vim ...
user avatar
  • 501
38 votes
4 answers
35k views

What is `softtabstop` used for?

I've been aware of these tab related settings in Vim: ts sw expandtab smarttab sts My normal setting is set ts=4 sw=4 expandtab smarttab. But according to sts documentation, if expandtab is not ...
user avatar
  • 543
36 votes
4 answers
12k views

Is it possible and useful to split vimrc?

As per the title, is it possible to split the vimrc file in several sub-files? Keep separate files for groups of settings that concern one thing? This thing might be anything, any kind of user-...
user avatar
31 votes
3 answers
9k views

How can I redefine plugin key mappings?

I have installed a plugin that doesn't provide a mechanism to disable the key mappings it defines. I want to redefine one of the mappings (<leader>cc) defined by the plugin for my own pursope, I'...
user avatar
  • 4,512
26 votes
2 answers
65k views

How do I configure the Vim airline plugin to look like its own project screenshot?

I am trying to get the vim-airline up and running. I have required it via vundle in my ~./vimrc: Plugin 'bling/vim-airline' I have installed it and expected my Vim to look like the screenshot on ...
user avatar
  • 2,787
25 votes
8 answers
8k views

Is there a best practice to fold a vimrc file

I recently realized that my vimrc is now more than 400 lines long (which IMO is too much I'll try to reduce that) and to make it easier to navigate, read and edit it I decided to investigate the ...
user avatar
  • 46.5k
25 votes
5 answers
2k views

GitHub for .vimrc and plugins

I know many people store their .vimrc on GitHub to make it easier to get right to work on new machines, and that makes complete sense to me. Including plugins, however, is problematic, because the ...
user avatar
  • 1,210
23 votes
6 answers
2k views

After copying a visual selection, return to original location

My cursor is in the middle of a paragraph when I decide suddenly I need to copy that paragraph: So I type vip to select the paragraph visually: Now I hit cmd+C to copy to clipboard (this may vary on ...
user avatar
  • 693
23 votes
4 answers
49k views

Remap Esc key in Vim

Is it possible to remap the Esc key to another key in Vim? When I'm using Vim in a full screen VMware vSphere web client console window and I press the Esc key to exit edit mode, it also takes me out ...
user avatar
22 votes
5 answers
13k views

Settings and plugins when root (`sudo vim`)?

It's really frustrating when I need to edit a file as root and use sudo vim somefile.conf and I can't use any of my keybindings and settings and plugins. Is there a way to get all my customizations ...
user avatar
22 votes
3 answers
2k views

The simplest way to start Vim in private mode

I want to be able to easily start Vim in a private mode. Let's define a private mode as one that utilizes this set of commands: set history=0 set nobackup set nomodeline set noshelltemp set ...
user avatar
21 votes
2 answers
2k views

What is the difference between set and :set (commands with or without a leading colon)?

I was looking at Tim Pope's vim-sensible plugin and I noticed this in the README... See the source for the authoritative list of features. (Don't worry, it's mostly :set calls.) When I looked at ...
user avatar
  • 453
20 votes
3 answers
17k views

How to make vim automatically add a newline to the end of a file?

Vim normally writes <EOL> for the last line only when there was one in the original file. How to make vim to write a new line at the end of a file all the time (when the file is not binary and ...
user avatar
  • 16.8k
20 votes
4 answers
4k views

How can I suppress the "reading from STDIN" message from within Vim?

When using Vim to read from stdin, it prints a informative message: $ echo foo | vim - Vim: Reading from stdin... $ This is just an example. The actual use doesn't allow shell constructs. vim <(...
user avatar
  • 23.9k
20 votes
1 answer
13k views

How can I add additional syntax highlighting rules in my local vimrc?

I installed gvim on both Fedora and Win7. I found that both vim and gvim on Fedora didn't highlight the function name in c code while gvim on win7 did highlight it. I found that on win7, vim73/...
user avatar
  • 801
19 votes
2 answers
4k views

How to define a custom popup / menu in vimrc

Assigning every useful function to a key works well for frequently used tools, but there are some operations I use so rarely, that I would prefer to assign them to some popup menu defined in my vimrc. ...
user avatar
  • 3,413
18 votes
2 answers
4k views

Vim cannot find medical spell files

Problem specification I would love to have a medical spell dictionary in vim. Currently, I have a lot of medical terms in my own personal English dictionary right now. However, using an official ...
user avatar
  • 567
18 votes
2 answers
992 views

How do I make Vim use a default filename when not given any filenames?

I rarely, if ever, just open vim without filenames. Often enough, I want to test something out, usually a quick throwaway script, and I usually name them test.sh (or some variant thereof, like test.py)...
user avatar
  • 23.9k
17 votes
5 answers
2k views

Why does this <Esc> normal mode mapping affect startup?

I'm experiencing a weird problem with a normal mode mapping of Esc. If you create the file escmapvimrc with the contents: set nocompatible set showcmd " Doesn't affect the problem: just makes it ...
user avatar
  • 28.2k
17 votes
4 answers
7k views

Includes in vimrc?

Is it possible to include external files to be sourced in the vimrc file? Is it as simple a matter as just adding source somefile?
user avatar
  • 3,141
16 votes
5 answers
14k views

How can put .vimrc and viminfo into .vim directory?

All the vim related files installed on /usr/share/vim/vim74. cd /home/debian8/ ls .vim* .viminfo .vimrc To create .vim directory to install some plugin for customization. mkdir .vim mkdir ....
user avatar
  • 860
16 votes
2 answers
13k views

How do I insert a comment into my vimrc fie?

What is the syntax for inserting a comment or comments into the vimrc file? Having trouble finding this on vim documentation online.
user avatar
16 votes
1 answer
19k views

Where do I put my "vimrc" file for Neovim on Windows?

:help nvim-from-vim says: create ~/.config/nvim/init.vim with these contents: set runtimepath+=~/.vim,~/.vim/after set packpath+=~/.vim source ~/.vimrc and: If your system sets $...
user avatar
16 votes
4 answers
11k views

How can I make highlighting commands in .vimrc take effect immediately with Vim 7.4?

I have several highlight commands in my .vimrc file. In Vim 7.3, these took effect immediately after Vim had started. After updating to Vim 7.4, this is not the case anymore. Vim uses its default ...
user avatar
15 votes
4 answers
2k views

How to label tmux tabs with the name of the file edited in vim?

Whenever I open a tmux session in terminal, all of the tabs containing vim sessions are labelled vim. My question is: How to configure it to label tmux tabs with the name of the edited file or ...
user avatar
15 votes
2 answers
7k views

How to deal with string containing spaces in Vim script?

I have the following command in my vimrc: execute "set path+=".getcwd()."/**" It works well if current working directory is like /home/tamlok/my_work/. However, if the directory contains spaces, ...
user avatar
  • 801
15 votes
2 answers
6k views

How can I modify Vim to work with a different keyboard layout?

I type with a non-QWERTY keyboard layout. Many of the keys Vim uses are now on the home row, but some key bindings just don't work, the most obvious one being the hjkl keys. How and where can I ...
user avatar
  • 313
14 votes
2 answers
4k views

How do you find where a variable was last assigned?

I am trying to set g:netrw_list_hide and it doesn't seem to work. No matter what I set it to in my .vimrc it always has the value ,^\.\.\=/\=$. Only if I source my vimrc file again, then it holds the ...
user avatar
  • 243
14 votes
3 answers
3k views

What's the difference between the '\zs' and '\@<=' atoms in Vim regex?

This is what I get from the documentation: \zs "starts the highlighted part" after matching the preceding regex, and \@<= "starts the highlighted part" after matching the ...
user avatar
  • 1,257
14 votes
1 answer
7k views

How to enable spell check for certain file types?

I flip between Ruby and Markdown files a lot. Is there a way that I can have set spell automatically set when I open a *.md file, but not when I open a *.rb one?
user avatar
14 votes
1 answer
20k views

How can I change the colour of the line highlighted with the 'cursorline' option?

I can highlight the current line like this :set cursorline, which underlines the current line. However I would like to highlight the entire line in a lighter color. How can I achieve this look?
user avatar
  • 1,425
14 votes
2 answers
13k views

Display CR and LF rather than "EOL" in ':set list'

Rather than choosing one character to be displayed as the EOL character, I'd like one to display for both CR and LF separately and regardless of if the file is unix or dos. Is this possible?
user avatar
13 votes
4 answers
1k views

Same vimrc, customized per machine [duplicate]

I use the same versioned .vimrc on several machines. Is there a way of customise that file to enable/disable a plugin based on machine name or something like that? As example, I have something like ...
user avatar
  • 285
13 votes
9 answers
32k views

Colorscheme's background not correct in terminal

I imported the solarized colorscheme and palette. My terminal has the correct colors and background, gvim has the correct colors and background, but vim has an incorrectly colored background. The text ...
user avatar
  • 191
13 votes
2 answers
12k views

How do I run a specific vim command when opening a file with a given extension?

I want all of my files ending in .tex to have line length 80. So whenever I open a .tex file in vim I type :set tw=79. What would I put in my .vimrc to automate this? What if I wanted it to work with ...
user avatar
  • 233
13 votes
1 answer
1k views

Why is it called a "vimrc" file?

Where did the name vimrc come from? Is the rc part an acronym? Are there historical reasons for picking this name? Where did the practice of using rc for configuration files first come from? For what ...
user avatar
  • 16.8k
13 votes
2 answers
10k views

Change color of CoC suggestion box

I successfully installed CoC in my Vim to have some code-suggestions/completions while coding in Rust. It works fine, but I want to change the color and basic looks of the suggestion box. I tried ...
user avatar
  • 283
13 votes
1 answer
4k views

How can I run an autocmd when starting Vim with no file, a non-existing file, or a blank file (but not when starting with an existing file)?

I would like to run an autocmd in the following scenarios when I start Vim: With no filename specified. When the file is new. When the file exists but is completely blank. In all of the above three ...
user avatar
13 votes
0 answers
268 views

Using <C-,> causes "<80>ü^D," to flash in the showcmd area?

I've mapped <C-,> as well as some other special keys (<C-Enter>, <C-S-Space>, ...) in my vimrc like, :set <F13>=^[[44;5u :map <F13> <C-,> :map! <F13> <C-...
user avatar
  • 1,200
12 votes
3 answers
436 views

UI to personalize a vimrc without writing one from scratch

Vim is so infinitely configurable. However, devising a vimrc is a daunting task for novices and intermediate users. Basically, you're expected to develop one from a blank slate by reading the ...
user avatar
  • 8,819
12 votes
2 answers
511 views

How to use sensitive data in .vimrc?

I want to have my .vimrc synced through github so it has to be public file, but at the same time i have to put some sensitive data (for example db passwords/hosts for dbext.vim) in it, without giving ...
user avatar
  • 1,478
12 votes
2 answers
10k views

What is the difference of using `au BufNewFile,BufRead *.py` and `au Filetype python` in .vimrc?

As I am setting .vimrc, I found these two code blocks have the same functionality. au Filetype python set \ tabstop=4 \ softtabstop=4 \ shiftwidth=4 \ textwidth=79 and au ...
user avatar
12 votes
1 answer
7k views

What is command! -bang -nargs=* in a vimrc file?

I read a document about vim and the author suggest a line of code that should be put in .vimrc but I totally have no idea what it is. command! -bang -nargs=* Find call fzf#vim#grep('rg --column --...
user avatar
  • 1,116

1
2 3 4 5
34