For example, why does this work:


(I had to enter visual to see the changes)

I was expecting a whitespace after edit, like:

edit /home/foo/bar.txt

I couldn't find a reference in the docs.

  • 3
    Probably for convenience. Vim is an interactive text editor; people want to perform their goals in the smallest amount of keypresses. So, in Vim script legacy, it is allowed for a command name to be immediately followed by an argument whose first character can't be part of the latter; e.g. :e#, :w/tmp/tt. Note that this is no longer allowed in Vim9 script.
    – user938271
    Jan 10 at 10:06
  • 1
    Welcome to Vi and Vim!
    – D. Ben Knoble
    Jan 10 at 15:16

I can't remember if it's documented anywhere, but Vim's parser skips over alphabetical characters (isalpha()) to find commands' end. Hence :edit/foo/bar/baz.txt works okay.

In fact, the whole story is more complicated, as there are numerous exceptions to this rule. The relevant source code is somewhere around this line.

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.