2

Perhaps this is a trivial question, but I have seen both of the following ways to enter in lines into the vimrc file:

:imap <leader>I <C-O>v <C-O>g

And

imap <leader>I <C-O>v <C-O>g

In other words, with/without the leading :. What is the proper way to do this, and is there any difference in the two?

0
3

In script files the leading : are optional. A script file is just a bunch of ex commands, that’s why they are allowed there, even when they are not necessary most of the time. Specifically the documentation says:

The ":" characters are not really needed here. You only need to use them when you type a command. In a Vim script file they can be left out. We will use them here anyway to make clear these are colon commands and make them stand out from Normal mode commands.

See :help vim-script-intro for details

2
  • 1
    thanks, the vim help keywords are almost impossible to guess! It would be great if there was some sort of search interface behind it so I could type something like :help "leading : in vimrc"
    – David542
    Apr 23 '20 at 21:14
  • Read :h help-summary. That should give you hints how to find something Apr 24 '20 at 5:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.