📄 change.txt
字号:
*v_>*{Visual}[count]> Shift the highlighted lines [count] 'shiftwidth' rightwards (for {Visual} see |Visual-mode|). {not in Vi} *:<*:[range]< Shift [range] lines one 'shiftwidth' left. Repeat '<' for shifting multiple 'shiftwidth's.:[range]< {count} Shift {count} lines one 'shiftwidth' left, starting with [range] (default current line |cmdline-ranges|). Repeat '<' for shifting multiple 'shiftwidth's.:[range]le[ft] [indent] left align lines in [range]. Sets the indent in the lines to [indent] (default 0). {not in Vi} *:>*:[range]> Shift {count} [range] lines one 'shiftwidth' right. Repeat '>' for shifting multiple 'shiftwidth's.:[range]> {count} Shift {count} lines one 'shiftwidth' right, starting with [range] (default current line |cmdline-ranges|). Repeat '>' for shifting multiple 'shiftwidth's.The ">" and "<" commands are handy for changing the indentation withinprograms. Use the 'shiftwidth' option to set the size of the white spacewhich these commands insert or delete. Normally the 'shiftwidth' option is 8,but you can set it to, say, 3 to make smaller indents. The shift leftwardsstops when there is no indent. The shift right does not affect empty lines.If the 'shiftround' option is on, the indent is rounded to a multiple of'shiftwidth'.If the 'smartindent' option is on, or 'cindent' is on and 'cinkeys' contains'#', shift right does not affect lines starting with '#' (these are supposedto be C preprocessor lines that must stay in column 1).When the 'expandtab' option is off (this is the default) Vim uses <Tab>s asmuch as possible to make the indent. You can use ">><<" to replace an indentmade out of spaces with the same indent made out of <Tab>s (and a few spacesif necessary). If the 'expandtab' option is on, Vim uses only spaces. Thenyou can use ">><<" to replace <Tab>s in the indent by spaces (or use":retab!").To move a line several 'shiftwidth's, use Visual mode or the ":" commands.For example:> Vjj4> move three lines 4 indents to the right> :<<< move current line 3 indents to the left> :>> 5 move 5 lines 2 indents to the right> :5>> move line 5 2 indents to the right==============================================================================4. Complex changes *complex-change* *!* *filter*!{motion}{filter} Filter {motion} text through the external program {filter}. *!!*!!{filter} Filter [count] lines through the external program {filter}. *v_!*{Visual}!{filter} Filter the highlighted lines through the external program {filter} (for {Visual} see |Visual-mode|). {not in Vi}:{range}![!]{filter} [!][arg] *:range!* Filter {range} lines through the external program {filter}. Vim replaces the optional bangs with the latest given command and appends the optional [arg]. Vim saves the output of the filter command in a temporary file and then reads the file into the buffer. Vim uses the 'shellredir' option to redirect the filter output to the temporary file. *=*={motion} Filter {motion} lines through the external program given with the 'equalprg' option. When the 'equalprg' option is empty (this is the default), use the internal formatting function to set the indent of each line |C-indenting|. *==*== Filter [count] lines through the external program given with the 'equalprg' option. When the 'equalprg' option is empty (this is the default), use the internal formatting function |C-indenting|. *v_=*{Visual}= Filter the highlighted lines through the external program given with the 'equalprg' option. When the 'equalprg' option is empty (this is the default), use the internal formatting function |C-indenting|. (for {Visual} see |Visual-mode|). {not in Vi}A filter is a program that accepts text at standard input, changes it in someway, and sends it to standard output. You can use the commands above to sendsome text through a filter. Examples of filters are "sort", which sorts linesalphabetically, and "indent", which formats C program files (you need aversion of indent that works like a filter; not all versions do). The 'shell'option specifies the shell Vim uses to execute the filter command (See alsothe 'shelltype' option). You can repeat filter commands with ".". Vim doesnot recognize a comment (starting with '"') after the ":!" command. *:s* *:su* *:substitute*:[range]s[ubstitute]/{pattern}/{string}/[c][e][g][p][r][i][I] [count] For each line in [range] replace a match of {pattern} with {string}. See |:s_flags| for the flags.:[range]s[ubstitute] [c][e][g][r][i][I] [count]:[range]&[c][e][g][r][i][I] [count] *:&* Repeat last :substitute with same search pattern and substitute string, but without the same flags. You may add extra flags (see |:s_flags|).:[range]~[c][e][g][r][i][I] [count] *:~* Repeat last substitute with same substitute string but with last used search pattern. This is like "&r". See |:s_flags| for the flags. *&*& Synonym for ":s//~/" (repeat last substitute). *:snomagic*:[range]sno[magic] ... Same as ":substitute", but always use 'nomagic'. {not in Vi} *:smagic*:[range]sm[agic] ... Same as ":substitute", but always use 'magic'. {not in Vi} *:s_flags*The arguments that you can use for the substitute commands:[c] Confirm each substitution. Vim positions the cursor on the matching string. You can type: *:s_c* 'y' to substitute this match 'n' to skip this match <Esc> to skip this match 'a' to substitute this and all remaining matches {not in Vi} 'q' to quit substituting {not in Vi} CTRL-E to scroll the screen up {not in Vi} CTRL-Y to scroll the screen down {not in Vi}. If the 'edcompatible' option is on, Vim remembers the [c] flag and toggles it each time you use it, but resets it when you give a new search pattern.[e] When the search pattern fails, do not issue an error message and, in particular, continue in maps as if no error occurred. This is most useful to prevent the "No match" error from breaking a mapping. Vim does not suppress the following error messages, however: Regular expressions can't be delimited by letters \ should be followed by /, ? or & No previous substitute regular expression Trailing characters Interrupted[g] Replace all occurrences in the line. Without this argument, replacement occurs only for the first occurrence in each line. If the 'edcompatible' option is on, Vim remembers this flag and toggles it each time you use it, but resets it when you give a new search pattern. If the 'gdefault' option is on, this flag is on by default and the [g] argument switches it off.[i] Ignore case for the pattern. The 'ignorecase' and 'smartcase' options are not used.[I] Don't ignore case for the pattern. The 'ignorecase' and 'smartcase' options are not used.[p] Print the line containing the last substitute.[r] Only useful in combination with ":&" or ":s" without arguments. ":&r" works the same way as ":~": When the search pattern is empty, use the previously used search pattern instead of the search pattern from the last substitute or ":global". If the last command that did a search was a substitute or ":global", there is no effect. If the last command was a search command such as "/", use the pattern from that command. For ":s" with an argument this already happens:> :s/blue/red/> /green> :s//red/ or :~ or :&r The last commands will replace "green" with "red".> :s/blue/red/> /green> :& The last command will replace "blue" with "red".Note that there is no flag to change the "magicness" of the pattern. Adifferent command is used instead. The reason is that the flags can only befound by skipping the pattern, and in order to skip the pattern the"magicness" must be known. Catch 22![count] Search [count] lines, starting with the last line number in [range] (default is to search only the current line |cmdline-ranges|).If the {pattern} for the substitute command is empty, the command uses thepattern from the last substitute or ":global" command. With the [r] flag, thecommand uses the pattern from the last substitute, ":global", or searchcommand.For compatibility with Vi these two exceptions are allowed:"\/{string}/" and "\?{string}?" do the same as "//{string}/r"."\&{string}&" does the same as "//{string}/".Instead of the '/' which surrounds the pattern and replacement string, youcan use any other character, but not an alphanumeric character, '\', '"' or'|'. This is useful if you want to include a '/' in the search pattern orreplacement string. Example:> :s+/+//+For the definition of a pattern, see |pattern|. *sub-replace-special*Some characters in {string} have a special meaning:magic nomagic action ~ & \& replaced with the whole matched pattern \& & replaced with & \0 replaced with the whole matched pattern \1 replaced with the matched pattern in the first pair of () \2 replaced with the matched pattern in the second pair of () .. .. \9 replaced with the matched pattern in the ninth pair of () ~ \~ replaced with the {string} of the previous substitute \~ ~ replaced with ~ \u next character made uppercase \U following characters made uppercase \l next character made lowercase \L following characters made lowercase \e end of \u, \U, \l and \L (NOTE: not <Esc>!) \E end of \u, \U, \l and \L <CR> split line in two at this point \r idem CTRL-V <CR> insert a carriage-return (CTRL-M) \n <NL> (does NOT break the line) \b <BS> \t <Tab>Examples:> :s/a\|b/xxx\0xxx/g modifies "a b" to "xxxaxxx xxxbxxx"> :s/\([abc]\)\([efg]\)/\2\1/g modifies "af fa bg" to "fa fa gb"> :s/abcde/abc^Mde/ modifies "abcde" to "abc", "de" (two lines)> :s/$/^V^M/ modifies "abcde" to "abcde^M"Note: To insert a ^M you have to type CTRL-V <CR>. To insert a ^V you haveto type CTRL-V CTRL-V. So to insert the ^V^M in the last example you have totype CTRL-V CTRL-V CTRL-V <CR>.Because CTRL-V <CR> inserts a <CR>, it is impossible to insert a CTRL-V justin front of a line break. You will have to perform the substitution in twosteps:> :s/foo/^Vxxxx/> :s/xxxx/^M/The numbering of "\1", "\2" etc. is done based on which "\(" comes first inthe pattern (going left to right). When a parentheses group matches severaltimes, the last one will be used for "\1", "\2", etc. Example:> :s/\(\(a[a-d] \)*\)/\2/ modifies "aa ab x" to "ab x"When using parentheses in combination with '|', like in \([ab]\)\|\([cd]\),either the first or second pattern in parentheses did not match, so either\1 or \2 is empty. Example:> :s/\([ab]\)\|\([cd]\)/\1x/g modifies "a b c d" to "ax bx x x" *:pro* *:promptfind*:promptf[ind] [string] Win32 GUI only: Put up a Search dialog. When [string] is given, it is used as the initial search string. *:promptr* *:promptrepl*:promptr[epl] [string] Win32 GUI only: Put up a Search/Replace dialog. When [string] is given, it is used as the initial search string. *:ret* *:retab*:[range]ret[ab][!] [new_tabstop] Replace all sequences of white-space containing a <Tab> with new strings of white-space using the new tabstop value given. If you do not specify a new tabstop size, Vim uses the current value of 'tabstop'. The current value of 'tabstop' is always used to compute the width of existing tabs. With !, Vim also replaces strings of only normal spaces with tabs where appropriate. With 'expandtab' on, Vim replaces all tabs with the appropriate number of spaces. This command sets 'tabstop' to the new value given, and if performed on the whole file, which is default, should not make any visible change. Careful: This command modifies any <Tab> characters inside of strings in a C program. Use "\t" to avoid this (that's a good habit anyway). ":retab!" may also change a sequence of spaces by <Tab> characters, which can mess up a printf(). {not in Vi} Not available when |+ex_extra| feature was disabled at compile time. *retab-example*Example for using autocommands and ":retab" to edit a file which is storedwith tabstops at 8 but edited with tabstops set at 4. Warning: white spaceinside of strings can change! Also see 'softtabstop' option.> auto BufReadPost *.xx retab! 4> auto BufWritePre *.xx retab! 8> auto BufWritePost *.xx retab! 4> auto BufNewFile *.xx set ts=4==============================================================================5. Copying and moving text *copy-move* *quote*"{a-zA-Z0-9.%#:-"} Use register {a-zA-Z0-9.%#:-"} for next delete, yank or put (use uppercase character to append with delete and yank) ({.%#:} only work with put). *:reg* *:registers*:reg[isters] Display the contents of all numbered and named registers. {not in Vi}:reg[isters] {arg} Display the contents of the numbered and named registers that are mentioned in {arg}. For example:> :dis 1a to display registers '1' and 'a'. Spaces are allowed in {arg}. {not in Vi} *:di* *:display*:di[splay] [arg] Same as :registers. {not in Vi} *y* *yank*["x]y{motion} Yank {motion} text [into register x]. When no characters are to be yanked (e.g., "y0" in column 1), this is an error when 'cpoptions' includes the 'E' flag. *yy*["x]yy Yank [count] lines [into register x] (linewise). *Y*["x]Y yank [count] lines [into register x] (synonym for yy, linewise). If you like "Y" to work from the cursor to the end of line (which is more logical, but not Vi-compatible) use ":map Y y$". *v_y*{Visual}["x]y Yank the highlighted text [into register x] (for {Visual} see |Visual-mode|). {not in Vi} *v_Y*{Visual}["x]Y Yank the highlighted lines [into register x] (for {Visual} see |Visual-mode|). {not in Vi} *:y* *:yank*:[range]y[ank] [x] Yank [range] lines [into register x].:[range]y[ank] [x] {count} Yank {count} lines, starting with last line number in [range] (default: current line |cmdline-ranges|), [into register x]. *p* *put*["x]p Put the text [from register x] after the cursor [count] times. {Vi: no count}["x]P or *P* *<MiddleMouse>*["x]<MiddleMouse> Put the text [from register x] before the cursor [count] times. Using the mouse only works when 'mouse' contains 'n' or 'a'. {Vi: no count}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -