[20191130]vim modeline.txt

lfree發表於2019-12-02

[20191130]vim modeline.txt

--//今天編輯檔案,發現每次開啟老是報錯,提示類似如下:
處理 modelines 時發生錯誤:
第    3 行:
E518: 未知的選項: this

$ cat a.txt

for ex: this is a test

--//輸入:help modeline,看到如下:

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 (<Space> or <Tab>)
{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)

Example:
   vi:noai:sw=3 ts=6 ~

The second form (this is compatible with some versions of Vi):

    [text]{white}{vi:|vim:|ex:}[white]se[t] {options}:[text]

[text]        any text or empty
{white}        at least one blank character (<Space> or <Tab>)
{vi:|vim:|ex:}    the string "vi:", "vim:" or "ex:"
[white]        optional white space
se[t]        the string "set " or "se " (note the space)
{options}    a list of options, separated with white space, which is the
        argument for a ":set" command
:        a colon
[text]        any text or empty

Example:
   /* vim: set ai tw=75: */

The white space before {vi:|vim:|ex:} is required.  This minimizes the chance
that a normal word like "lex:" is caught.  There is one exception: "vi:" and
"vim:" can also be at the start of the line (for compatibility with version
3.0).  Using "ex:" at the start of the line will be ignored (this could be
short for "example:").

--//原來這種模式控制檔案的顯示模式以及設定,做一個記錄.一般在開頭以及結尾的5行.
--//一些開發會使用一些特殊的定義.
--//假設定義如下,開啟檔案就會在列10,20,40出現彩色的豎線
/* vim: set colorcolumn=10,20,40: */

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2666408/,如需轉載,請註明出處,否則將追究法律責任。