📄 options.txt
字号:
This can be used to set options for files matching a particular pattern and many other things. See |autocommand|.3. 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. This is explained here. *modeline* *vim:* *vi:* *ex:*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 white space (<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" commandExample:> vi:noai:sw=3 ts=6The second form (this is compatible with some versions of Vi): [text]{white}{vi:|vim:|ex:}[white]set {options}:[text][text] any text or empty{white} at least one white space (<Space> or <Tab>){vi:|vim:|ex:} the string "vi:", "vim:" or "ex:"[white] optional white spaceset the string "set " (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 emptyExample:> /* vim: set ai tw=75: */The white space before {vi:|vim:|ex:} is required. This minimizes the chancethat 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 version3.0). Using "ex:" at the start of the line will be ignored (this could beshort for "example:").The number of lines that are checked can be set with the 'modelines' option.If 'modeline' is off or 'modelines' is 0 no lines are checked.Note that for the first form all of the rest of the line is used, thus a linelike:> /* vi:ts=4: */will give an error message for the trailing "*/". This line is OK:> /* vi:set ts=4: */If an error is detected the rest of the line is skipped.If you want to include a ':' in a set command precede it with a '\'. Thebackslash in front of the ':' will be removed. Example:> /* vi:set dir=c\:\tmp: */This sets the 'dir' option to "c:\tmp". Only a single backslash before the':' is removed. Thus to include "\:" you have to specify "\\:".No other commands than "set" are supported, for security reasons (somebodymight create a Trojan horse text file with modelines).==============================================================================3. Saving settings *save-settings* *:mk* *:mkexrc*:mk[exrc] [file] Write current key mappings and changed options to [file] (default ".exrc" in the current directory), unless it already exists. {not in Vi}:mk[exrc]! [file] Always write current key mappings and changed options to [file] (default ".exrc" in the current directory). {not in Vi} *:mkv* *:mkvimrc*:mkv[imrc][!] [file] Like ":mkexrc", but the default is ".vimrc" in the current directory. The ":version" command is also written to the file. {not in Vi} *:mks* *:mksession*:mks[ession][!] [file] Like ":mkvimrc", but write commands to the end of the file that reload the files being edited at the time of the command. |session-file| The default file name is "Session.vim". The created file can be loaded with a |:source| command to recreate the current edit session. {not in Vi} {only when compiled with the |+mksession| feature enabled}These commands will write ":map" and ":set" commands to a file, in such a waythat when these commands are executed, the current key mappings and optionswill be set to the same values. The options 'columns', 'endofline','fileformat', 'key', 'lines', 'modified', 'scroll', 'term', 'textmode','ttyfast' and 'ttymouse' are not included, because these are terminal or filedependent. Note that the options 'binary', 'paste' and 'readonly' areincluded, this might not always be what you want.When special keys are used in mappings, The 'cpoptions' option will betemporarily made empty, to avoid the mappings to be misinterpreted. Thismakes the file incompatible with Vi, but makes sure it can be used withdifferent terminals.A common method is to use a default ".vimrc" file, make some modificationswith ":map" and ":set" commands and write the modified file. First read thedefault ".vimrc" in with a command like ":source ~piet/.vimrc.Cprogs", changethe settings and then save them in the current directory with ":mkvimrc!". Ifyou want to make this file your default .vimrc, move it to your home directory(on Unix), s: (Amiga) or $VIM directory (MS-DOS). You could also useautocommands |autocommand| and/or modelines |modeline|.If you only want to add a single option setting to your vimrc, you can usethese steps:1. Edit your vimrc file with Vim.2. Play with the option until it's right. E.g., try out different values for 'guifont'.3. Append a line to set the value of the option, using the expression register '=' to enter the value. E.g., for the 'guifont' option:> o:set guifont=<C-R>=&guifont<CR><Esc> [<C-R> is a CTRL-R, <CR> is a return, <Esc> is the escape key]Note that when you create a .vimrc file, this can influence the 'compatible'option, which has several side effects. See |'compatible'|.":mkvimrc", ":mkexrc" and ":mksession" write the command to set or reset the'compatible' option to the output file first, because of these side effects. *session-file*You can use session files to quickly switch between different projects,automatically loading the files you were last working on in that project.Session files are a nice addition to viminfo-files, which are used to rememberinformation for all sessions together |viminfo-file|.The output of ":mksession" is like ":mkvimrc", but additional commands areadded to the file. Which ones depends on the 'sessionoptions' option. Theresulting file, when executed with a ":source" command:1. Restores mappings and options, if 'sessionoptions' contains "options".2. Restores global variables that start with an uppercase letter and contain at least one lowercase letter, if 'sessionoptions' contains "globals".3. Unloads all currently loaded buffers.4. Restores the working directory.5. Restores GUI vim window position, if 'sessionoptions' contains "winpos".6. Restores screen height, if 'sessionoptions' contains "resize".7. Reloads the files you were editing, at the lines where you left them. If 'sessionoptions' contains "buffers" then all buffers are restored, including hidden and unloaded buffers. Otherwise only buffers in windows are restored.8. Restores windows, if 'sessionoptions' contains "winsize". If the Vim window size has been restored or is already the same as in the loaded session, the window sizes are restored exactly. Otherwise, the windows are just given sensible sizes9. If a file exists with the same name as the session file, but ending in "x.vim" (for eXtra), executes that as well. You can use *x.vim files to specify additional settings and actions associated with a given session, such as creating menu items in the GUI version.The full filename of your current session is available in the internalvariable "v:this_session". See |this_session-variable|.So an example mapping might be (all one line):> :nmap <S-F1> :wa<Bar>exe "mksession! " . v:this_session<CR>:so $VIM/sessions/which saves the files and session, and starts off the command to load another.==============================================================================4. Options summary *option-summary*In the list below all the options are mentioned with their full name and withan abbreviation if there is one. Both forms may be used.In this document when a boolean option is "set" that means that ":set option"is entered. When an option is "reset", ":set nooption" is used.For some options there are two default values: The "Vim default", which isused when 'compatible' is not set, and the "Vi default", which is used when'compatible' is set.Most options are the same in all windows and buffers. There are a few thatare specific to how the text is presented in a window. These can be set to adifferent value in each window. For example the 'list' option can be set inone window and reset in another for the same text, giving both types of viewat the same time. There are a few options that are specific to a certainfile. These can have a different value for each file or buffer. For examplethe 'textwidth' option can be 78 for a normal text file and 0 for a Cprogram. global one option for all buffers and windows local to window each window has its own copy of this option local to buffer each buffer has its own copy of this optionWhen creating a new window the option values from the currently active windoware used as a default value for the window-specific options. For thebuffer-specific options this depends on the 's' and 'S' flags in the'cpoptions' option. If 's' in included (which is the default) the values forbuffer options are copied from the currently active buffer when a buffer isfirst entered. If 'S' is present the options are copied each time the bufferis entered, this is almost like having global options. If 's' and 'S' are notpresent, the options are copied from the currently active buffer when thebuffer is created.A jump table for the options with a short description can be found at |X_op|. *'aleph'* *'al'* *aleph* *Aleph*'aleph' 'al' number (default 128 for MS-DOS, 224 otherwise) global {not in Vi} {only available when compiled with the |+rightleft| feature} The ASCII code for the first letter of the Hebrew alphabet. The routine that maps the keyboard in Hebrew mode, both in Insert mode (when hkmap is set) and on the command-line (when hitting CTRL-_) outputs the Hebrew characters in the range [aleph..aleph+26]. aleph=128 applies to PC code, and aleph=224 applies to ISO 8859-8. See |rightleft.txt|. *'allowrevins'* *'ari'* *'noallowrevins'* *'noari'*'allowrevins' 'ari' boolean (default off) global {not in Vi} {only available when compiled with the |+rightleft| feature} Allow CTRL-_ in Insert and Command-line mode. This is default off, to avoid that users that accidentally type CTRL-_ instead of SHIFT-_ get into reverse Insert mode, and don't know how to get out. See 'revins'. NOTE: This option is reset when 'compatible' is set. *'altkeymap'* *'akm'* *'noaltkeymap'* *'noakm'*'altkeymap' 'akm' boolean (default off) global {not in Vi} {only available when compiled with the |+farsi| feature} When on, the second language is Farsi. In editing mode CTRL-_ toggles the keyboard map between Farsi and English, when 'allowrevins' set. When off, the keyboard map toggles between Hebrew and English. This is useful to start the vim in native mode i.e. English (left-to-right mode) and have default second language Farsi or Hebrew (right-to-left mode). See |farsi.txt|. *'autoindent'* *'ai'* *'noautoindent'* *'noai'*'autoindent' 'ai' boolean (default off) local to buffer Copy indent from current line when starting a new line (typing <CR> in Insert mode or when using the "o" or "O" command). If you do not type anything on the new line except <BS> and then type <Esc> or <CR>, the indent is deleted again. When autoindent is on, formatting (with the "gq" command or when you reach 'textwidth' in Insert mode) uses the indentation of the first line. When 'smartindent' or 'cindent' is on the indent is changed in specific cases. The 'autoindent' option is reset when the 'paste' option is set. {small difference from Vi: After the indent is deleted when typing <Esc> or <CR>, the cursor position when moving up or down is after the deleted indent; Vi puts the cursor somewhere in the deleted indent}. *'autowrite'* *'aw'* *'noautowrite'* *'noaw'*'autowrite' 'aw' boolean (default off) global Write the contents of the file, if it has been modified, on each :next, :rewind, :previous, :stop, :suspend, :tag, :!, :make, CTRL-] and CTRL-^ command; and when a CTRL-O, CTRL-I, '{A-Z0-9}, or `{A-Z0-9} command takes one to another file. *'background'* *'bg'*'background' 'bg' string (default "dark" or "light") global {not in Vi} When set to "dark", Vim will try to use colors that look good on a dark background. When set to "light", Vim will try to use colors that look good on a light background. Any other value is illegal. Vim tries to set the default value according to the terminal used. This will not always be correct. Setting this option does not change the background color, it tells Vim what the backround color looks like. For changing the background color, see |:hi-normal|. When starting the GUI, the default value for 'background' will be "light". When the value is not set in the .gvimrc, and Vim detects that the background is actually quite dark, 'background' is set to "dark". But this happens only AFTER the .gvimrc file has been read (because the window needs to be opened to find the actual background color). To get around this, force the GUI window to be opened by putting a ":gui" command in the .gvimrc file, before where the value of 'background' is used (e.g., before ":syntax on"). For the Win32 GUI, setting 'background' before starting the GUI, will change the background and foreground colors to lightgrey on black or black on white. On other systems setting 'background' does not change the foreground or background colors. Normally this option would be set in the .vimrc file. Possibly depending on the terminal name. Example:> if &term == "pcterm"> set background=dark> endif When this option is set, the default settings for the highlight groups will change. To use other settings, place ":highlight" commands AFTER the setting of the 'background' option. This option is also used in the "$VIMRUNTIME/syntax/syntax.vim" file to select the colors for syntax highlighting. After changing this
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -