Skip to main content
162 votes

How to share config between Vim and Neovim

TL;DR You can use your existing ~/.vimrc, files, and plugins located within ~/.vim without having to symlink the files. And this is now documented in NeoVim manual, see Transitioning from Vim. For ...
ipatch's user avatar
  • 1,899
47 votes
Accepted

Vim cannot find medical spell files

The "medical" spell file does not exist, it is just an example of a name that is longer than two characters. You would have to generate one yourself.
Bram Moolenaar's user avatar
35 votes
Accepted

Remap Esc key in Vim

Usually, C-[ is also a way to get out of insert mode. Some people like to map jj in insert mode as a way to exit and return to normal mode. I personally prefer jh as my fingers 'slide' better with ...
Amir Eldor's user avatar
31 votes

What is `softtabstop` used for?

The value of 'softtabstop' equals how many columns (=spaces) the cursor moves right when you press <Tab>, and how many columns it moves left when you press <BS> (backspace) to erase a tab. ...
Arminius's user avatar
  • 411
26 votes

How do you find where a variable was last assigned?

If you were looking for the last point where an option was set (instead of a variable), you could use the :verbose command: :4verbose set is? incsearch Last set from ~/.vim/vimrc But ...
mMontu's user avatar
  • 6,670
26 votes

How to share config between Vim and Neovim

You can use if has('nvim'). Here are complete examples: Configuration only for Neovim: if has('nvim') tnoremap <Esc> <C-\><C-n> endif Configuration only for Vim if !has('...
Mark Stosberg's user avatar
26 votes

Remap Esc key in Vim

TL;DR It's actually nice to remap esc to the home row. Here's how you decide what to map it to: pick a hand and roll your 4 fingers across your desktop as fast as you can in whichever direction is ...
Bruno Bronosky's user avatar
26 votes

Vim cannot find medical spell files

In response to Bram's answer, I have found, modified, and compiled a medical spell file that can be used with Vim. I've made the full instructions and the source code available under a GPL3 license ...
melvio's user avatar
  • 617
24 votes

Fastest way to switch to a buffer in Vim?

:CtrlPBuffer from plugin CtrlP (5k ★) Main feature of this plugin is to provide a fuzzy matching to conveniently open a different buffer with visual feedback. Open the fuzzy buffer listing with :...
Hotschke's user avatar
  • 4,790
24 votes
Accepted

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

However after adding these lines into the .vimrc, it didn't work. The reason for this is that Vim clears existing syntax items when setting the 'syntax' option. This is done because keeping the old ...
Martin Tournoij's user avatar
23 votes

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

You don't need any shell configuration to store your .vimrc file in the .vim directory. You just need to remove the . or _ from the filename. Vim looks in the following locations by default on ...
Rich's user avatar
  • 32.1k
22 votes
Accepted

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

As always, the help is your best friend: :h :command: :com[mand][!] [{attr}...] {cmd} {rep} Define a user command. The name of the command is {cmd} and its replacement text is {rep}. The ...
statox's user avatar
  • 50.1k
22 votes
Accepted

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

Your intuition is correct: the two autocommands are very similar. The second autocommand runs when you read or start editing a new file with a name that ends in the .py extension. The first runs when ...
Rich's user avatar
  • 32.1k
22 votes

Convert a search to a command in Vim

You could just do: %s//REPLACEMENT/ From the docs: If the {pattern} for the substitute command is empty, the command uses the pattern from the last substitute or :global command. If there is ...
Ralf's user avatar
  • 9,277
21 votes
Accepted

Includes in vimrc?

Unlike :source, :runtime doesn't need an absolute path to work. It is much better than :source for building portable setups. See :help :runtime. In the following example, we tell Vim to look for a ...
romainl's user avatar
  • 41.1k
21 votes
Accepted

Why is it called a "vimrc" file?

The Unix section of the wiki page on configuration files, leads to the wiki page on run commands, which is where the rc comes from. Quoting from the run commands page: In the context of Unix-like ...
Herb's user avatar
  • 1,213
21 votes
Accepted

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

Neovim looks for ~\AppData\Local\nvim\init.vim to run at startup. If you want to create the suggested init.vim from :help nvim-from-vim, save the following instead: set runtimepath+=~/vimfiles,~/...
Michael Kropat's user avatar
20 votes

Most annoying slow-down of a plain-text editor!

Can somebody tell me how to avoid the very annoying vim's slowdown? Hopefully in a user friendly non-geeky way? I run Vim on a company-provided 2013 15" Retina MacBook with a 2.3 GHz i7 processor, 16 ...
romainl's user avatar
  • 41.1k
19 votes
Accepted

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

This looks like you indeed found an obscure bug. I have implemented the gn textobject back in 2012 for Vim 7.3 something. It basically works in the following way: 1) It searches backwards for the ...
Christian Brabandt's user avatar
19 votes
Accepted

Change color of CoC suggestion box

I don't use coc, so I will just share my vision on how you can try to fix this. I assume that by suggestion box you mean regular vim Pmenu. Try to make sure if it is actually Pmenu: run :hi Pmenu ...
Maxim Kim's user avatar
  • 13.6k
18 votes

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

What if you want to move everything? Although the answers here are correct, they miss something. The OP's question didn't ask about how to change everything, just .vimrc and .viminfo. Then to achieve ...
DrBeco's user avatar
  • 370
18 votes
Accepted

How to share config between Vim and Neovim

Having your config in Neovim's default location, do the following: mkdir -p ~/.local/share/nvim/site ln -s ~/.local/share/nvim/site ~/.vim ln -s .config/nvim/init.vim .vimrc To fix the colorscheme ...
lumbric's user avatar
  • 1,549
18 votes
Accepted

Convert a search to a command in Vim

In command-line, you can use ctrl-r (see :h c_ctrl-r) to start inserting the content of a register. In your case, you could paste the content of the last search with: <c-r>/ Another way would ...
Biggybi's user avatar
  • 2,770
18 votes
Accepted

Variable vs global variable

In VimScript all variables have a scope. Or, better to say, they are organized into :h Dictionaries with reserved names. So echo g: is a perfectly valid command. There are the following scopes (...
Matt's user avatar
  • 20.8k
17 votes
Accepted

How do I insert a comment into my vimrc fie?

It's in a different help file (cmdline, help :comment): *:quote* *:comment* '"' at the start of a line causes the whole line to be ignored. '"' after a command causes the ...
xaizek's user avatar
  • 1,798
16 votes
Accepted

How to restore bash terminal title if using 'set title' in vim?

Use the titleold setting: " Update term title but restore old title after leaving Vim set title set titleold= From :help 'titleold': This option will be used for the window title when exiting Vim ...
Martin Tournoij's user avatar
16 votes
Accepted

Echo message on startup without prompting

You might want to use an autocommand that runs after VimEnter is triggered. The autocommand can look something like this: autocmd VimEnter * echo 'foo' When vim starts up, it runs the command, and ...
DoYouEvenCodeBro's user avatar
16 votes
Accepted

How do you find where a variable was last assigned?

You can capture a full log of a Vim session with vim -V20vimlog. After quitting Vim, examine (search, grep) the vimlog log file for :let g:netrw_list_hide.
Ingo Karkat's user avatar
  • 17.9k
15 votes
Accepted

Same vimrc, customized per machine

You can access your environment variable and external command from vim, so you can do: if system('uname') =~ "Darwin" echo 'mac' else echo 'other' endif Note that you can use =~ instead of ...
nobe4's user avatar
  • 16.1k
15 votes
Accepted

How to break a long mapping line into several short lines in vimrc mapping

You can split your long line by inserting a Vim line continuation character (backslash) at the beginning of each continued line: nnoremap <space>e \ :exe "!tmux send-keys -t.- 'cd $TEST'...
nst0022's user avatar
  • 506

Only top scored, non community-wiki answers of a minimum length are eligible