What is Vim's feature name for this: # vim:sw=4:ts=4:et:

后端 未结 3 899
醉话见心
醉话见心 2021-02-07 13:06

Even after 20 years with Vim, I keep forgetting name for the Vim feature where the editor picks up config statements from a comment at the beginning (or I think end) of a file:<

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-07 13:34

    It's called modeline

    :he modeline
    

    If you start editing a new file, and the 'modeline' option is on, a number of lines at the beginning and end of the file are checked for modelines. There are two forms of modelines.

      The first form:   [text]{white}{vi:|vim:|ex:}[white]{options}
    
     [text]         any text or empty
     {white}        at least one blank character ( or )
     {vi:|vim:|ex:} the string "vi:", "vim:" or "ex:"
     [white]        optional white space
     {options}      a list of option settings, separated with white space or ':',
                    where each part between ':' is the argument for a ":set"
                    command (can be empty)
    

    Add this to $MYVIMRC:

    setglobal modeline
    

提交回复
热议问题