2

Apparently, multiple colons are simply ignored when executing Ex commands. For example,

:set number!
:::set number!
: :  :set number!

all toggle line numbers. Is this really a consolidated rule? Where is it documentated? I tried :helpgrep :: and :help :: but did not find anything relevant.

I came to this question after many times having copied Ex commands such as :set number! and pasted to Vim's command line with :CTRL+R*, so that the resulting command line had a double colon.

3

Yes, the leading colons and blanks are ignored. It is documented in the Command Line Parsing section of the POSIX specification of Ex.

Command-line parsing shall be done in the following steps. For each step, characters already evaluated shall be ignored; that is, the phrase "leading character" refers to the next character that has not yet been evaluated.

  1. Leading <colon> characters shall be skipped.

  2. Leading <blank> characters shall be skipped.

Also, down below the informative section reiterates it:

Historically, ex permitted a single extra <colon> as a leading command character; for example, :g/pattern/:p was a valid command. POSIX.1-2017 generalizes this to require that any number of leading <colon> characters be stripped.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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