Which characters in a vimscript command are invalid?

Is there are blacklist or a whitelist of characters?

Currently, I've only come up with these characters that trigger the error

Invalid command name

  • _
  • -
  • .
  • !
  • :



See :help user-commands

All user defined commands must start with an uppercase letter, to avoid confusion with builtin commands. Exceptions are these builtin commands: :Next :X They cannot be used for a user defined command. ":Print" is also an existing command, but it is deprecated and can be overruled.

The other characters of the user command can be uppercase letters, lowercase letters or digits. When using digits, note that other commands that take a numeric argument may become ambiguous. For example, the command ":Cc2" could be the user command ":Cc2" without an argument, or the command ":Cc" with argument "2". It is advised to put a space between the command name and the argument to avoid these problems.

When using a user-defined command, the command can be abbreviated. However, if an abbreviation is not unique, an error will be issued. Furthermore, a built-in command will always take precedence.

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.