📄 vip.texinfo
字号:
commands etc.* New Commands:: Some new commands not available in Vi are added.* New Bindings:: Bindings of some keys are changed for the convenience of editing under Emacs.* Window Commands:: Commands for moving among windows etc.* Buffer Commands:: Commands for selecting buffers etc.* File Commands:: Commands for visiting files etc.* Misc Commands:: Other useful commands.@end menu@node Undoing, Changing, Differences from Vi, Differences from Vi@subsection Undoing@kindex 165 @kbd{u} (@code{vip-undo})@kindex 056 @kbd{.} (@code{vip-repeat})You can repeat undoing by the @kbd{.} key. So, @kbd{u} will undoa single change, while @kbd{u .@: .@: .@:}, for instance, will undo 4 previouschanges. Undo is undoable as in Vi. So the content of the buffer willbe the same before and after @kbd{u u}.@refill@node Changing, Searching, Undoing, Differences from Vi@subsection ChangingSome commands which change a small number of characters are executedslightly differently. Thus, if point is at the beginning of a word@samp{foo} and you wished to change it to @samp{bar} by typing @w{@kbd{c w}},then VIP will prompt you for a new word in the minibuffer by the prompt@samp{foo => }. You can then enter @samp{bar} followed by @key{RET} or@key{ESC} to complete the command. Before you enter @key{RET} or@key{ESC} you can abort the command by typing @kbd{C-g}. In general,@kindex 007 @kbd{C-g} (@code{vip-keyboard-quit})you can abort a partially formed command by typing @kbd{C-g}.@refill@node Searching, z Command, Changing, Differences from Vi@subsection Searching@kindex 057 @kbd{/} (@code{vip-search-forward})@kindex 077 @kbd{?} (@code{vip-search-backward})As in Vi, searching is done by @kbd{/} and @kbd{?}. The string will besearched literally by default. To invoke a regular expression search,first execute the search command @kbd{/} (or @kbd{?}) with empty searchstring. (I.e, type @kbd{/} followed by @key{RET}.)A search for empty string will toggle the search mode between vanillasearch and regular expression search. You cannot give an offset to thesearch string. (It is a limitation.) By default, search will wrap aroundthe buffer as in Vi. You can change this by rebinding the variable@code{vip-search-wrap-around}. @xref{Customization}, for how to do this.@refill@node z Command, Counts, Searching, Differences from Vi@subsection z Command@kindex 1723 @kbd{z H} (@code{vip-line-to-top})@kindex 1721 @kbd{z RET} (@code{vip-line-to-top})@kindex 1723 @kbd{z M} (@code{vip-line-to-middle})@kindex 1722 @kbd{z .} (@code{vip-line-to-middle})@kindex 1723 @kbd{z L} (@code{vip-line-to-bottom})@kindex 1722 @kbd{z -} (@code{vip-line-to-bottom})For those of you who cannot remember which of @kbd{z} followed by @key{RET},@kbd{.}@: and @kbd{-} do what. You can also use @kbd{z} followed by @kbd{H},@kbd{M} and @kbd{L} to place the current line in the Home (Middle, andLast) line of the window.@refill@node Counts, Marking, z Command, Differences from Vi@subsection CountsSome Vi commands which do not accept a count now accept one@table @kbd@item p@itemx P@kindex 160 @kbd{p} (@code{vip-put-back})@kindex 120 @kbd{P} (@code{vip-Put-back})Given counts, text will be yanked (in Vi's sense) that many times. Thus@kbd{3 p} is the same as @kbd{p p p}.@item o@itemx O@kindex 157 @kbd{o} (@code{vip-open-line})@kindex 117 @kbd{O} (@code{vip-Open-line})Given counts, that many copies of text will be inserted. Thus@kbd{o a b c @key{ESC}} will insert 3 lines of @samp{abc} below the currentline.@item /@itemx ?@kindex 057 @kbd{/} (@code{vip-search-forward})@kindex 077 @kbd{?} (@code{vip-search-backward})Given a count @var{n}, @var{n}-th occurrence will be searched.@end table@node Marking, Region Commands, Counts, Differences from Vi@subsection MarkingTyping an @kbd{m} followed by a lower case character @var{ch} marks thepoint to the register named @var{ch} as in Vi. In addition to these, wehave following key bindings for marking.@kindex 155 @kbd{m} (@code{vip-mark-point})@table @kbd@item m <Set mark at the beginning of buffer.@item m >Set mark at the end of buffer.@item m .Set mark at point (and push old mark on mark ring).@item m ,Jump to mark (and pop mark off the mark ring).@end table@node Region Commands, New Commands, Marking, Differences from Vi@subsection Region Commands@cindex regionVi operators like @kbd{d}, @kbd{c} etc. are usually used in combinationwith motion commands. It is now possible to use current region as theargument to these operators. (A @dfn{region} is a part of bufferdelimited by point and mark.) The key @kbd{r} is used for this purpose.Thus @kbd{d r} will delete the current region. If @kbd{R} is used insteadof @kbd{r} the region will first be enlarged so that it will become thesmallest region containing the original region and consisting of wholelines. Thus @kbd{m .@: d R} will have the same effect as @kbd{d d}.@refill@node New Commands, New Bindings, Region Commands, Differences from Vi@subsection Some New CommandsNote that the keys below (except for @kbd{R}) are not used in Vi.@table @kbd@item C-a@kindex 001 @kbd{C-a} (@code{vip-beginning-of-line})Move point to the beginning of line.@item C-n@kindex 016 @kbd{C-n} (@code{vip-next-window})If you have two or more windows in the screen, this key will move point tothe next window.@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.@item C-r@kindex 022 @kbd{C-r} (@code{isearch-backward})Backward incremental search.@item C-s@kindex 023 @kbd{C-s} (@code{isearch-forward})Forward incremental search.@item C-c@itemx C-x@itemx @key{ESC}@kindex 003 @kbd{C-c} (@code{vip-ctl-c})@kindex 0300 @kbd{C-x} (@code{vip-ctl-x})@kindex 033 @kbd{ESC} (@code{vip-ESC})These keys will exit from vi mode and return to emacs mode temporarily. Ifyou hit one of these keys, Emacs will be in emacs mode and will believethat you hit that key in emacs mode. For example, if you hit @kbd{C-x}followed by @kbd{2}, then the current window will be split into 2 and youwill be in vi mode again.@item \@kindex 134 @kbd{\} (@code{vip-escape-to-emacs})Escape to emacs mode. Hitting @kbd{\} will take you to emacs mode, and youcan execute a single Emacs command. After executing the Emacs command youwill be in vi mode again. You can give a count before typing @kbd{\}.Thus @kbd{5 \ *}, as well as @kbd{\ C-u 5 *}, will insert @samp{*****}before point. Similarly @kbd{1 0 \ C-p} will move the point 10 lines abovethe current line.@refill@item K@kindex 113 @kbd{K} (@code{vip-kill-buffer})Kill current buffer if it is not modified. Useful when you selected abuffer which you did not want.@item Q@itemx R@kindex 121 @kbd{Q} (@code{vip-query-replace})@kindex 122 @kbd{R} (@code{vip-replace-string})@kbd{Q} is for query replace and @kbd{R} is for replace. By default,string to be replaced are treated literally. If you wish to do a regularexpression replace, first do replace with empty string as the string to bereplaced. In this way, you can toggle between vanilla and regularexpression replacement.@item v@itemx V@kindex 166 @kbd{v} (@code{vip-find-file})@kindex 126 @kbd{V} (@code{vip-find-file-other-window})These keys are used to Visit files. @kbd{v} will switch to a buffervisiting file whose name can be entered in the minibuffer. @kbd{V} issimilar, but will use window different from the current window.@item #@kindex 0430 @kbd{#} (@code{vip-command-argument})If followed by a certain character @var{ch}, it becomes an operator whoseargument is the region determined by the motion command that follows.Currently, @var{ch} can be one of @kbd{c}, @kbd{C}, @kbd{g}, @kbd{q} and@kbd{s}.@refill@item # c@kindex 0432 @kbd{# c} (@code{downcase-region})Change upper case characters in the region to lower case(@code{downcase-region}).@item # C@kindex 0431 @kbd{# C} (@code{upcase-region})Change lower case characters in the region to upper case. For instance,@kbd{# C 3 w} will capitalize 3 words from the current point(@code{upcase-region}).@item # g@kindex 0432 @kbd{# g} (@code{vip-global-execute})Execute last keyboard macro for each line in the region(@code{vip-global-execute}).@refill@item # q@kindex 0432 @kbd{# q} (@code{vip-quote-region})Insert specified string at the beginning of each line in the region(@code{vip-quote-region}).@item # s@kindex 0432 @kbd{# s} (@code{spell-region})Check spelling of words in the region (@code{spell-region}).@item *@kindex 052 @kbd{*} (@code{vip-call-last-kbd-macro})Call last keyboard macro.@end table@node New Bindings, Window Commands, New Commands, Differences from Vi@subsection New Key BindingsIn VIP the meanings of some keys are entirely different from Vi. These keybindings are done deliberately in the hope that editing under Emacs willbecome easier. It is however possible to rebind these keys to functionswhich behave similarly as in Vi. @xref{Customizing Key Bindings}, fordetails.@table @kbd@item C-g@itemx g@kindex 007 @kbd{C-g} (@code{vip-keyboard-quit})@kindex 147 @kbd{g} (@code{vip-info-on-file})In Vi, @kbd{C-g} is used to get information about the file associated tothe current buffer. Here, @kbd{g} will do that, and @kbd{C-g} isused to abort a command (this is for compatibility with emacs mode.)@item SPC@itemx @key{RET}@kindex 040 @kbd{SPC} (@code{vip-scroll})@kindex 015 @kbd{RET} (@code{vip-scroll-back})Now these keys will scroll up and down the text of current window.Convenient for viewing the text.@item s@itemx S@kindex 163 @kbd{s} (@code{vip-switch-to-buffer})@kindex 123 @kbd{S} (@code{vip-switch-to-buffer-other-window})They are used to switch to a specified buffer. Useful for switching toalready existing buffer since buffer name completion is provided. Alsoa default buffer will be given as part of the prompt, to which you canswitch by just typing @key{RET} key. @kbd{s} is used to select bufferin the current window, while @kbd{S} selects buffer in another window.@item C@itemx X@kindex 103 @kbd{C} (@code{vip-ctl-c-equivalent})@kindex 1300 @kbd{X} (@code{vip-ctl-x-equivalent})These keys will exit from vi mode and return to emacs mode temporarily.If you type @kbd{C} (@kbd{X}), Emacs will be in emacs mode and will believethat you have typed @kbd{C-c} (@kbd{C-x}, resp.) in emacs mode. Moreover,if the following character you type is an upper case letter, then Emacswill believe that you have typed the corresponding control character.You will be in vi mode again after the command is executed. For example,typing @kbd{X S} in vi mode is the same as typing @kbd{C-x C-s} in emacsmode. You get the same effect by typing @kbd{C-x C-s} in vi mode, butthe idea here is that you can execute useful Emacs commands without typingcontrol characters. For example, if you hit @kbd{X} (or @kbd{C-x}) followedby @kbd{2}, then the current window will be split into 2 and you will be invi mode again.@refill@end tableIn addition to these, @code{ctl-x-map} is slightly modified:@kindex 1301 @kbd{X 3} (@code{vip-buffer-in-two-windows})@table @kbd@item X 3@itemx C-x 3This is equivalent to @kbd{C-x 1 C-x 2} (1 + 2 = 3).@end table@node Window Commands, Buffer Commands, New Bindings, Differences from Vi@subsection Window CommandsIn this and following subsections, we give a summary of key bindings forbasic functions related to windows, buffers and files.@table @kbd@item C-n@kindex 016 @kbd{C-n} (@code{vip-next-window})Switch to next window.@item X 1@itemx C-x 1@kindex 1301 @kbd{X 1} (@code{delete-other-windows})Delete other windows.@item X 2@itemx C-x 2@kindex 1301 @kbd{X 2} (@code{split-window-vertically})Split current window into two windows.@item X 3@itemx C-x 3@kindex 1301 @kbd{X 3} (@code{vip-buffer-in-two-windows})Show current buffer in two windows.@end table@node Buffer Commands, File Commands, Window Commands, Differences from Vi@subsection Buffer Commands@table @kbd@item s@kindex 163 @kbd{s} (@code{vip-switch-to-buffer})Switch to the specified buffer in the current window(@code{vip-switch-to-buffer}).@item S@kindex 123 @kbd{S} (@code{vip-switch-to-buffer-other-window})Switch to the specified buffer in another window(@code{vip-switch-to-buffer-other-window}).@item K@kindex 113 @kbd{K} (@code{vip-kill-buffer})Kill the current buffer if it is not modified.@item X S@itemx C-x C-s@kindex 1302 @kbd{X S} (@code{save-buffer})Save the current buffer in the file associated to the buffer.@end table@node File Commands, Misc Commands, Buffer Commands, Differences from Vi@subsection File Commands@table @kbd@item v@kindex 166 @kbd{v} (@code{vip-find-file})Visit specified file in the current window.@item V@kindex 126 @kbd{V} (@code{vip-find-file-other-window})Visit specified file in another window.@item X W@itemx C-x C-w@kindex 1302 @kbd{X W} (@code{write-file})Write current buffer into the specified file.@item X I
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -