📄 vip.texinfo
字号:
command above will become the count for the associated motion command.Thus, @kbd{3 d w} will delete three words.@kindex 042 @kbd{"} (@code{vip-command-argument})It is also possible to save the deleted text into a register you specify.For example, you can say @kbd{" t 3 d w} to delete three words and save itto register @kbd{t}. The name of a register is a lower case letter between@kbd{a} and @kbd{z}. If you give an upper case letter as an argument toa delete command, then the deleted text will be appended to the content ofthe register having the corresponding lower case letter as its name. So,@kbd{" T d w} will delete a word and append it to register @kbd{t}. Othermodifying commands also accept a register name as their argument, and wewill not repeat similar explanations.We have more delete commands as below.@table @kbd@item d d@kindex 1442 @kbd{d d}Delete a line. Given a count @var{n}, delete @var{n} lines.@item d r@kindex 1442 @kbd{d r}Delete current region.@item d R@kindex 1441 @kbd{d R}Expand current region and delete it.@item D@kindex 104 @kbd{D} (@code{vip-kill-line})Delete to the end of a line (@code{vip-kill-line}).@item x@kindex 170 @kbd{x} (@code{vip-delete-char})Delete a character after point. Given @var{n}, delete @var{n} characters(@code{vip-delete-char}).@item @key{DEL}@kindex 177 @kbd{DEL} (@code{vip-delete-backward-char})Delete a character before point. Given @var{n}, delete @var{n} characters(@code{vip-delete-backward-char}).@end table@node Yank Commands, Put Back Commands, Delete Commands, Modifying Commands@subsection Yank Commands@cindex yankYank commands @dfn{yank} a text of buffer into a (usually anonymous) register.Here the word `yank' is used in Vi's sense. Thus yank commands do notalter the content of the buffer, and useful only in combination withcommands that put back the yanked text into the buffer.@table @kbd@item y @var{motion-command}@kindex 1710 @kbd{y} (@code{vip-command-argument})Yank the region determined by the motion command @var{motion-command}.@end table@noindentFor example, @kbd{y $} will yank the text between point and the end of lineinto an anonymous register, while @kbd{"c y $} will yank the same text intoregister @kbd{c}.Use the following command to yank consecutive lines of text.@table @kbd@item y y@itemx Y@kindex 131 @kbd{Y} (@code{vip-yank-line})@kindex 1712 @kbd{y y} (@code{vip-yank-line})Yank a line. Given @var{n}, yank @var{n} lines (@code{vip-yank-line}).@item y r@kindex 1712 @kbd{y r}Yank current region.@item y R@kindex 1711 @kbd{y R}Expand current region and yank it.@end table@node Put Back Commands, Change Commands, Yank Commands, Modifying Commands@subsection Put Back CommandsDeleted or yanked texts can be put back into the buffer by the commandbelow.@table @kbd@item p@kindex 160 @kbd{p} (@code{vip-put-back})Insert, after the character point is looking at, most recentlydeleted/yanked text from anonymous register. Given a register nameargument, the content of the named register will be put back. Given acount, the command will be repeated that many times. This command alsochecks if the text to put back ends with a new line character, and if sothe text will be put below the current line (@code{vip-put-back}).@item P@kindex 120 @kbd{P} (@code{vip-Put-back})Insert at point most recently deleted/yanked text from anonymous register.Given a register name argument, the content of the named register willbe put back. Given a count, the command will be repeated that many times.This command also checks if the text to put back ends with a new linecharacter, and if so the text will be put above the current line ratherthan at point (@code{vip-Put-back}).@end table@noindent@cindex number registerThus, @kbd{" c p} will put back the content of the register @kbd{c} into thebuffer. It is also possible to specify @dfn{number register} which is anumeral between @kbd{1} and @kbd{9}. If the number register @var{n} isspecified, @var{n}-th previously deleted/yanked text will be put back. Itis an error to specify a number register for the delete/yank commands.@node Change Commands, Repeating and Undoing Modifications, Put Back Commands, Modifying Commands@subsection Change CommandsMost commonly used change command takes the following form.@table @kbd@item c @var{motion-command}@kindex 1430 @kbd{c} (@code{vip-command-argument})Replace the content of the region determined by the motion command@var{motion-command} by the text you type. If the motion command is apoint command then you will type the text into minibuffer, and if themotion command is a line command then the region will be deleted first andyou can insert the text in @var{insert mode}.@end table@noindentFor example, if point is at the beginning of a word @samp{foo} and youwish to change it to @samp{bar}, you can type @kbd{c w}. Then, as @kbd{w}is a point command, you will get the prompt @samp{foo =>} in theminibuffer, for which you can type @kbd{b a r @key{RET}} to complete the changecommand.@refill@table @kbd@item c c@kindex 1432 @kbd{c c}Change a line. Given a count, that many lines are changed.@item c r@kindex 1432 @kbd{c r}Change current region.@item c R@kindex 1431 @kbd{c R}Expand current region and change it.@end table@node Repeating and Undoing Modifications, Other Vi Commands, Change Commands, Modifying Commands@subsection Repeating and Undoing ModificationsVIP records the previous modifying command, so that it is easy to repeatit. It is also very easy to undo changes made by modifying commands.@table @kbd@item u@kindex 165 @kbd{u} (@code{vip-undo})Undo the last change. You can undo more by repeating undo by the repeatcommand @samp{.}. For example, you can undo 5 previous changes by typing@samp{u....}. If you type @samp{uu}, then the second @samp{u} undoes thefirst undo command (@code{vip-undo}).@item .@kindex 056 @kbd{.} (@code{vip-repeat})Repeat the last modifying command. Given count @var{n} it becomes the newcount for the repeated command. Otherwise, the count for the lastmodifying command is used again (@code{vip-repeat}).@end table@node Other Vi Commands, Commands in Insert Mode, Repeating and Undoing Modifications, Vi Commands@section Other Vi CommandsMiscellaneous Vi commands are collected here.@table @kbd@item Z Z@kindex 132 @kbd{Z Z} (@code{save-buffers-kill-emacs})Exit Emacs. If modified buffers exist, you will be asked whether you wishto save them or not (@code{save-buffers-kill-emacs}).@item !@: @var{motion-command} @var{format-command}@itemx @var{n} !@: !@: @var{format-command}@kindex 041 @kbd{!} (@code{vip-command-argument})The region determined by the motion command @var{motion-command} will begiven to the shell command @var{format-command} and the region will bereplaced by its output. If a count is given, it will be passed to@var{motion-command}. For example, @samp{3!Gsort} will sort the regionbetween point and the 3rd line. If @kbd{!} is used instead of@var{motion-command} then @var{n} lines will be processed by@var{format-command} (@code{vip-command-argument}).@item J@kindex 112 @kbd{J} (@code{vip-join-lines})Join two lines. Given count, join that many lines. A space will beinserted at each junction (@code{vip-join-lines}).@item < @var{motion-command}@itemx @var{n} < <@kindex 074 @kbd{<} (@code{vip-command-argument})Shift region determined by the motion command @var{motion-command} toleft by @var{shift-width} (default is 8). If @kbd{<} is used instead of@var{motion-command} then shift @var{n} lines@*(@code{vip-command-argument}).@item > @var{motion-command}@itemx @var{n} > >@kindex 076 @kbd{>} (@code{vip-command-argument})Shift region determined by the motion command @var{motion-command} toright by @var{shift-width} (default is 8). If @kbd{<} is used instead of@var{motion-command} then shift @var{n} lines@*(@code{vip-command-argument}).@item = @var{motion-command}@kindex 075 @kbd{=} (@code{vip-command-argument})Indent region determined by the motion command @var{motion-command}. If@kbd{=} is used instead of @var{motion-command} then indent @var{n} lines(@code{vip-command-argument}).@item *@kindex 052 @kbd{*} (@code{vip-call-last-kbd-macro})Call last remembered keyboard macro.@item #A new vi operator. @xref{New Commands}, for more details.@end tableThe following keys are reserved for future extensions, and currentlyassigned to a function that just beeps (@code{vip-nil}).@kindex 046 @kbd{&} (@code{vip-nil})@kindex 100 @kbd{@@} (@code{vip-nil})@kindex 125 @kbd{U} (@code{vip-nil})@kindex 133 @kbd{[} (@code{vip-nil})@kindex 135 @kbd{]} (@code{vip-nil})@kindex 137 @kbd{_} (@code{vip-nil})@kindex 161 @kbd{q} (@code{vip-nil})@kindex 176 @kbd{~} (@code{vip-nil})@example&, @@, U, [, ], _, q, ~@end exampleVIP uses a special local keymap to interpret key strokes you enter in vimode. The following keys are bound to @var{nil} in the keymap. Therefore,these keys are interpreted by the global keymap of Emacs. We give below ashort description of the functions bound to these keys in the globalkeymap. See GNU Emacs Manual for details.@table @kbd@item C-@@@kindex 000 @kbd{C-@@} (@code{set-mark-command})Set mark and push previous mark on mark ring (@code{set-mark-command}).@item TAB@kindex 011 @kbd{TAB} (@code{indent-for-tab-command})Indent line for current major mode (@code{indent-for-tab-command}).@item LFD@kindex 012 @kbd{LFD} (@code{newline-and-indent})Insert a newline, then indent according to mode (@code{newline-and-indent}).@item C-k@kindex 013 @kbd{C-k} (@code{kill-line})Kill the rest of the current line; before a newline, kill the newline.With prefix argument, kill that many lines from point. Negative argumentskill lines backward (@code{kill-line}).@item C-l@kindex 014 @kbd{C-l} (@code{recenter})Clear the screen and reprint everything (@code{recenter}).@item @var{n} C-p@kindex 020 @kbd{C-p} (@code{previous-line})Move cursor vertically up @var{n} lines (@code{previous-line}).@item C-q@kindex 021 @kbd{C-q} (@code{quoted-insert})Read next input character and insert it. Useful for inserting controlcharacters@*(@code{quoted-insert}).@item C-r@kindex 022 @kbd{C-r} (@code{isearch-backward})Search backward incrementally (@code{isearch-backward}).@item C-s@kindex 023 @kbd{C-s} (@code{isearch-forward})Search forward incrementally (@code{isearch-forward}).@item @var{n} C-t@kindex 024 @kbd{C-t} (@code{transpose-chars})Interchange charcters around point, moving forward one character. Withcount @var{n}, take character before point and drag it forward past @var{n}other characters. If no argument and at end of line, the previous twocharacters are exchanged (@code{transpose-chars}).@item @var{n} C-v@kindex 026 @kbd{C-v} (@code{scroll-up})Scroll text upward @var{n} lines. If @var{n} is not given, scroll nearfull screen (@code{scroll-up}).@item C-w@kindex 027 @kbd{C-w} (@code{kill-region})Kill between point and mark. The text is save in the kill ring. Thecommand @kbd{P} or @kbd{p} can retrieve it from kill ring(@code{kill-region}).@end table@node Commands in Insert Mode, Ex Commands, Other Vi Commands, Vi Commands@section Insert ModeYou can enter insert mode by one of the following commands. In addition tothese, you will enter insert mode if you give a change command with a linecommand as the motion command. Insert commands are also modifying commandsand you can repeat them by the repeat command @kbd{.} (@code{vip-repeat}).@table @kbd@item i@kindex 151 @kbd{i} (@code{vip-insert})Enter insert mode at point (@code{vip-insert}).@item I@kindex 111 @kbd{I} (@code{vip-Insert})Enter insert mode at the first non white character on the line(@code{vip-Insert}).@item a@kindex 141 @kbd{a} (@code{vip-append})Move point forward by one character and then enter insert mode(@code{vip-append}).@item A@kindex 101 @kbd{A} (@code{vip-Append})Enter insert mode at end of line (@code{vip-Append}).@item o@kindex 157 @kbd{o} (@code{vip-open-line})Open a new line below the current line and enter insert mode(@code{vip-open-line}).@item O@kindex 117 @kbd{O} (@code{vip-Open-line})Open a new line above the current line and enter insert mode(@code{vip-Open-line}).@item C-o@kindex 017 @kbd{C-o} (@code{vip-open-line-at-point})Insert a newline and leave point before it, and then enter insert mode@*(@code{vip-open-line-at-point}).@end tableInsert mode is almost like emacs mode. Only the following 4 keys behavedifferently from emacs mode.@table @kbd@item @key{ESC}@kindex 033 @kbd{ESC} (@code{vip-change-mode-to-vi}) (insert mode)This key will take you back to vi mode (@code{vip-change-mode-to-vi}).@item C-h@kindex 010 @kbd{C-h} (@code{delete-backward-char}) (insert mode)Delete previous character (@code{delete-backward-char}).@item C-w@kindex 027 @kbd{C-w} (@code{vip-delete-backward-word}) (insert mode)Delete previous word (@code{vip-delete-backward-word}).@item C-z@kindex 032 @kbd{C-z} (@code{vip-ESC}) (insert mode)This key simulates @key{ESC} key in emacs mode. For instance, typing@kbd{C-z x} in insert mode iw the same as typing @kbd{ESC x} in emacs mode(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -