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 the source, the :set calls are like this...

set autoindent

There's no : before the set.

I'm pretty sure I've actually seen :set in example .vimrcs also.

What is the difference?

Which form should I use in my .vimrc?

2 Answers 2


A "script" does nothing more than run a sequence of ex commands. An "ex command" is what you type when you use : in Vim. For example :wq, :set wrap, :e file, etc. are all ex commands.

The : is not part of the command; it is merely a keystroke to start the command-line mode; you don't always need to include the :, for example when you chain multiple commands with | you don't need to repeat the : more than once. For example, :write | quit will work fine.

For convenience, the : may be included though. This aids with copy/pasting and such, but you don't have to. It doesn't matter. In fact, all leading :s are simply ignored. :write, write, and :::::::::write are all equivalent in terms of functionality (although obviously not in terms of sanity).

It's often useful to include the : in documentation to clarify that this is an ex command. For example w could refer either to :w or the normal mode command w to go to the next word.

Note that this applies to everything. Control structures such as if and endif are also just ex commands; you can type something like this:

:if 1
:echo 'one'

from the Vim commandline just fine; no need for a "script". Vim scripts are very "non-magic" and "non-special"; everything you can do from the ex commandline you can do in a Vim script, and vice versa.


There is no difference. If vim sees a : before a command in your vimrc (or any vimscript file) it will ignore it. Also, as mentioned above, this isn't specific to the set command.

Usually the : means that the command would be run by you instead of being put in your vimrc (or other vimscript file), but that usually depends on the context. Personally I think it looks much better to not put the colon before commands in vimscript files, and that seems to be what most other people do as well.

For more on this see :help script.

  • :h script or :h vim-script-intro (equivalent)
    – VanLaser
    Commented Mar 5, 2016 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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