📄 options.txt
字号:
*options.txt* For Vim version 5.8. Last change: 2001 Feb 27 VIM REFERENCE MANUAL by Bram MoolenaarOptions *options*1. Setting options |set-option|2. Automatically setting options |auto-setting|3. Saving settings |save-settings|4. Options summary |option-summary|For an overview of options see help.txt |option-list|.Vim has a number of internal variables and switches which can be set toachieve special effects. These options come in three forms: boolean can only be on or off *boolean* *toggle* number has a numeric value string has a string value==============================================================================1. Setting options *set-option* *:se* *:set*:se[t] Show all options that differ from their default value.:se[t] all Show all but terminal options.:se[t] termcap Show all terminal options. Note that in the GUI the key codes are not shown, because they are generated interally and can't be changed. Changing the terminal codes in the GUI is not useful either...:se[t] {option}? Show value of {option}.:se[t] {option} Toggle option: set, switch it on. Number option: show value. String option: show value.:se[t] no{option} Toggle option: Reset, switch it off.:se[t] {option}! or:se[t] inv{option} Toggle option: Invert value. {not in Vi}:se[t] {option}& Reset option to its default value. {not in Vi}:se[t] all& Set all options, except terminal options, to their default value. The values of 'term', 'lines' and 'columns' are not changed. {not in Vi}:se[t] {option}={value} or:se[t] {option}:{value} Set string or number option to {value}. *:set-args* For numeric options the value can be given in decimal, hex (preceded with 0x) or octal (preceded with '0') (hex and octal are only available for machines which have the strtol() function). The old value can be inserted by typing 'wildchar' (by default this is a <Tab> or CTRL-E if 'compatible' is set). See |cmdline-completion|. White space between {option} and '=' is allowed and will be ignored. White space between '=' and {value} is not allowed. See |option-backslash| for using white space and backslashes in {value}.:se[t] {option}+={value} *:set+=* Add the {value} to a number option, or append the {value} to a string option. When the option is a comma separated list, a comma is added, unless the value was empty. There is no check for doubled values. You can avoid this by removing a value first. Example:> set guioptions-=T guioptions+=T Also see |:set-args| above.:se[t] {option}^={value} *:set^=* Multiply the {value} to a number option, or prepend the {value} to a string option. When the option is a comma separated list, a comma is added, unless the value was empty. Also see |:set-args| above.:se[t] {option}-={value} *:set-=* Subtract the {value} from a number option, or remove the {value} from a string option, if it is there. If the {value} is not found in a string option, there is no error or warning. When the option is a comma separated list, a comma is deleted, unless the option becomes empty. Also see |:set-args| above.:bro[wse] se[t] *:set-browse* *:browse-set* *:opt* *:options*:opt[ions] Open a window for viewing and setting all options. Options are grouped by function. Offers short help for each option. Hit <CR> on the short help to open a help window with more help for the option. Modify the value of the option and hit <CR> on the "set" line to set the new value. For window and buffer specific options, the last accessed window is used to set the option value in, unless this is a help window, in which case the window below help window is used (skipping the option-window). {not available when compiled without the |+eval| or |+autocmd| features}The {option} arguments to ":set" may be repeated. For example:> :set ai nosi sw=3 ts=3If you make an error in one of the arguments, an error message will be givenand the following arguments will be ignored.For {option} the form "t_xx" may be used to set a termcap option. This willoverride the value from the termcap. You can then use it in a mapping. Ifthe "xx" part contains special characters, use the <t_xx> form: :set <t_#4>=^[OtThe listing from ":set" looks different from Vi. Long string options are putat the end of the list. The number of options is quite large. The output of"set all" probably does not fit on the screen, causing Vim to give the|more-prompt|. *option-backslash*To include white space in a string option value it has to be preceded with abackslash. To include a backslash you have to use two. Effectively thismeans that the number of backslashes in an option value is halved (roundeddown).A few examples:> :set tags=tags\ /usr/tags results in "tags /usr/tags"> :set tags=tags\\,file results in "tags\,file"> :set tags=tags\\\ file results in "tags\ file"For MS-DOS and WIN32 backslashes in file names are mostly not removed. Moreprecise: For options that expect a file name (those where environmentvariables are expanded) a backslash before a normal file name character is notremoved. But a backslash before a special character (space, backslash, comma,etc.) is used like explained above.There is one special situation, when the value starts with "\\":> :set dir=\\machine\path results in "\\machine\path"> :set dir=\\\\machine\\path results in "\\machine\path"> :set dir=\\path\\file results in "\\path\file" (wrong!)For the first one the start is kept, but for the second one the backslashesare halved. This makes sure it works both when you expect backslashes to behalved and when you expect the backslashes to be kept. The third gives aresult which is probably not what you want. Avoid it. *add-option-flags* *remove-option-flags*Some options are a list of flags. When you want to add a flag to such anoption, without changing the existing ones, you can do it like this:> :set guioptions+=aRemove a flag from an option like this:> :set guioptions-=aThis removes the 'a' flag from 'guioptions'.Note that you should add or remove one flag at a time. If 'guioptions' hasthe value "ab", using "set guioptions-=ba" won't work, because the string "ba"doesn't appear. *:set_env* *expand-env* *expand-environment-var*Environment variables in most string options will be expanded. If theenvironment variable exists the '$' and the following environment variablename is replaced with its value. If it does not exist the '$' and the nameare not modified. Any non-id character (not a letter, digit or '_') mayfollow the environment variable name. That character and what follows isappended to the value of the environment variable. Examples:> :set term=$TERM.new> :set path=/usr/$INCLUDE,$HOME/include,. *$HOME*Using "~" is like using "$HOME", but it is only recognized at the start of anoption and after a space or comma.On Unix systems "~user" can be used too. It is replaced by the home directoryof user "user". Example:> :set path=~mool/include,/usr/include,.On Unix systems the form "${HOME}" can be used too. The name between {} cancontain non-id characters then. Note that if you want to use this for the"gf" command, you need to add the '{' and '}' characters to 'isfname'. *$VIM*The environment variable "$VIM" is used to locate various user files for Vim,such as the user startup script ".vimrc". This depends on the system, see|startup|.To avoid the need for every user to set the $VIM environment variable, Vimwill try to get the value for $VIM in this order:1. The value defined by the $VIM environment variable. You can use this to make Vim look in a specific directory for its support files. Example:> setenv VIM /home/paul/vim2. The path from 'helpfile' is used, unless it contains some environment variable too (the default is "$VIMRUNTIME/doc/help.txt": chicken-egg problem). The file name ("help.txt" or any other) is removed. Then trailing directory names are removed, in this order: "doc", "runtime" and "vim{version}" (e.g., "vim54").3. For MSDOS, Win32 and OS/2 Vim tries to use the directory name of the executable. If it ends in "/src", this is removed. This is useful if you unpacked the .zip file in some directory, and adjusted the search path to find the vim executable. Trailing directory names are removed, in this order: "runtime" and "vim{version}" (e.g., "vim54").4. For Unix the compile-time defined installation directory is used (see the output of ":version").Once Vim has done this once, it will set the $VIM environment variable. Tochange it later, use a ":let" command like this:> let $VIM = "/home/paul/vim/" *$VIMRUNTIME*The environment variable "$VIMRUNTIME" is used to locate various supportfiles, such as the on-line documentation and files used for syntaxhighlighting. For example, the main help file is normally"$VIMRUNTIME/doc/help.txt".You don't normally set $VIMRUNTIME youself, but let Vim figure it out. Thisis the order used to find the value of $VIMRUNTIME:1. If the environment variable $VIMRUNTIME is set, it is used. You can use this when the runtime files are in an unusual location.2. If "$VIM/vim{version}" exists, it is used. {version} is the version number of Vim, without any '-' or '.'. For example: "$VIM/vim54". This is the normal value for $VIMRUNTIME.3. If "$VIM/runtime" exists, it is used.4. The value of $VIM is used. This is for backwards compatibility with older versions.5. When the 'helpfile' option is set and doesn't contain a '$', its value is used, with "doc/help.txt" removed from the end.For Unix, when there is a compiled-in default for $VIMRUNTIME (check theoutput of ":version"), steps 2, 3 and 4 are skipped, and the compiled-indefault is used after step 5. This means that the compiled-in defaultoverrules the value of $VIM. This is useful if $VIM is "/etc" and the runtimefiles are in "/user/share/vim/vim54".Once Vim has done this once, it will set the $VIMRUNTIME environment variable.To change it later, use a ":let" command like this:> let $VIMRUNTIME = "/home/piet/vim/vim54"Note the maximum length of an expanded option is limited. How much depends onthe system, mostly it is something like 256 or 1024 characters. *:fix* *:fixdel*:fix[del] Set the value of 't_kD': 't_kb' is 't_kD' becomes ~ CTRL-? CTRL-H not CTRL-? CTRL-? (CTRL-? is 0177 octal, 0x7f hex) {not in Vi} If your delete key terminal code is wrong, but the code for backspace is alright, you can put this in your .vimrc:> :fixdel This works no matter what the actual code for backspace is. If the backspace key terminal code is wrong you can use this:> :if &term == "termname"> : set t_kb=^V<BS>> : fixdel> :endif Where "^V" is CTRL-V and "<BS>" is the backspace key (don't type four characters!). Replace "termname" with your terminal name. If your <Delete> key sends a strange key sequence (not CTRL-? or CTRL-H) you cannot use ":fixdel". Then use:> :if &term == "termname"> : set t_kD=^V<Delete>> :endif Where "^V" is CTRL-V and "<Delete>" is the delete key (don't type eight characters!). Replace "termname" with your terminal name. *Linux-backspace* Note about Linux: By default the backspace key produces CTRL-?, which is wrong. You can fix it by putting this line in your rc.local:> echo "keycode 14 = BackSpace" | loadkeys *NetBSD-backspace* Note about NetBSD: If your backspace doesn't produce the right code, try this this:> xmodmap -e "keycode 22 = BackSpace" If this works, add this in your .Xmodmap file:> keysym 22 = BackSpace You need to restart for this to take effect.==============================================================================2. Automatically setting options *auto-setting*Besides changing options with the ":set" command, there are three alternativesto set options automatically for one or more files:1. When starting Vim initializations are read from various places. See |initialization|. Most of them are performed for all editing sessions, and some of them depend on the directory where Vim is started.2. If you start editing a new file, the automatic commands are executed.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -