I am trying to load a barebones vim. So I defined a ~/.slimvimrc which has the following contents
syntax on
map q :q <cr>
Then I load vim using vim -u ~/.slimvimrc. When I press q I expect vim to close because of the mapping above. However, vim just 'sits' on the command line printing q<CR> and waits for input.
However , if I add nocp setting to the above vimrc :
syntax on
set nocp
map q :q <cr>
the mapping works fine. I looked up the documentation of nocp, but unable to locate it's relation with <CR>. Can you point me the right place?
Your mapping doesn't work in "compatible mode" because
<is not recognized as starting a key code.Your
~/.slimvimrcshould look like this:Note the specificity of
nnoremap:nmeans "normal mode",noremeans "non-recursive",and the removed space between
:qand<CR>.Anyway,
q<char>is used to start a recording in register<char>. That feature is awesome! Overriding it with a custom mapping doesn't sound like a very good idea.Also, you can call Vim with the
-Nargument to force'nocompatible':