1

In Vim, what characters are allowed in identifiers, such as variable names and function names?

I looked up the help for both variables and functions and neither one defines the allowable character set or syntax for valid identifiers.

2

From :h 41.2

*41.2*  Variables

A variable name consists of ASCII letters, digits and the underscore.  It
cannot start with a digit.  Valid variable names are:

    counter
    _aap3
    very_long_variable_name_with_underscores
    FuncLength
    LENGTH

Invalid names are "foo+bar" and "6var".

And I think it's the same for functions, note that user defined functions must start with an uppercase letter (except from scriptlocal functions beginning with s: as pointed out @D. Ben Knoble in the comments)

  • Except scriptlocal s: functions, I think – D. Ben Knoble Oct 2 '18 at 16:38
  • 1
    @D.BenKnoble You're right (but even for script local function I like to use the upper case to keep a consistent naming :) ) – statox Oct 3 '18 at 7:41

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.