Mercurial > hg > xemacs-beta
diff man/viper.texi @ 163:0132846995bd r20-3b8
Import from CVS: tag r20-3b8
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:43:35 +0200 |
parents | 43dd3413c7c7 |
children | 2d532a89d707 |
line wrap: on
line diff
--- a/man/viper.texi Mon Aug 13 09:42:28 2007 +0200 +++ b/man/viper.texi Mon Aug 13 09:43:35 2007 +0200 @@ -4,9 +4,9 @@ \input texinfo @comment Using viper.info instead of viper in setfilename breaks DOS. -@setfilename viper -@comment @setfilename ../info/viper +@comment @setfilename viper @comment @setfilename viper.info +@setfilename ../info/viper @iftex @finalout @@ -15,7 +15,7 @@ @titlepage @title Viper Is a Package for Emacs Rebels @subtitle a Vi emulator for GNU Emacs 19 and XEmacs 19 -@subtitle May 1997, Viper Version 2.93 +@subtitle June 1997, Viper Version 2.94 @author Masahiko Sato (VIP 3.5) @author Aamod Sane (VIP 4.4) @@ -146,7 +146,7 @@ You should also learn to use the Info on-line hypertext manual system that comes with Emacs. This manual can be read as an Info file. Try the command -@kbd{ESC x info} with vanilla Emacs sometime. +@kbd{@key{ESC} x info} with vanilla Emacs sometime. Comments and bug reports are welcome. @code{kifer@@cs.sunysb.edu} is the current address for Viper bug reports. @@ -288,7 +288,7 @@ in a manner similar to the Control key, e.g., @kbd{M-x} means typing @kbd{x} while holding the Meta key down. For keyboards that do not have a Meta key, @key{ESC} is used as Meta. -Thus @kbd{M-x} is typed as @kbd{ESC x}. Viper uses @key{ESC} to switch +Thus @kbd{M-x} is typed as @kbd{@key{ESC} x}. Viper uses @key{ESC} to switch from Insert state to Vi state. Therefore Viper defines @kbd{C-\} as its Meta key in Vi state. @xref{Vi State}, for more info.@refill @@ -299,73 +299,39 @@ @node Loading Viper, States in Viper, Emacs Preliminaries, Overview @section Loading Viper -First, make sure that all six Viper files @file{viper*.el} are somewhere on -Emacs @dfn{load path}. The load path is a list of directories where Emacs -looks for its Lisp code; it is similar to Unix environment variable -@var{PATH}. The load path is determined by the Lisp variable -@code{load-path}. - -Type @code{C-h v load-path RET} to check the current load path of your -Emacs. (Here and later, @kbd{RET} stands for carriage return.) If the files -@file{viper*.el} are not in any directory on the load path, you should -create your own directory and put it on the load path; then put -@file{viper*.el} in that directory. To put a new directory, say -@file{~/emacslib}, on your load path, add the following line at the -beginning of your @file{~/.emacs} file: -@lisp -(setq load-path (cons "~/emacslib" load-path)) -@end lisp -It is recommended that you compile @file{viper.el} by running -@example -make all -@end example -in the directory where Viper was unpacked. The best way to ensure that -Viper is installed properly is to run -@example -make install -@end example -in the directory where Viper was unpacked. See README in the Viper -distribution for the details on which modifications to the make file may be -necessary. - -Once Viper is settled on the load path, -the most common way to load it automatically is to include the line: +The most common way to load it automatically is to include the lines (in +the given order!): @lisp +(setq viper-mode t) (require 'viper) @end lisp @noindent -in your @file{~/.emacs} file. The @file{.emacs} file is placed in your home -directory and it will be executed every time you invoke Emacs. -Viper also uses the file @file{~/.vip} for Viper-specific customization. -If you wish -to be in Vi command state whenever this is appropriate, you can include the -following -line in your @file{.vip}: +in your @file{~/.emacs} file. The @file{.emacs} file is placed in your +home directory and it is be executed every time you invoke Emacs. Viper +also uses the file @file{~/.viper} for Viper-specific customization. If you +wish to be in Vi command state whenever this is deemed appropriate by the +author, you can include the following line in your @file{.viper}: @lisp -(setq vip-always t) +(setq viper-always t) @end lisp @noindent -(@xref{Vi State}, for the explanation of Vi mode.) +(@xref{Vi State}, for the explanation of Vi command state.) Once invoked, Viper will arrange to bring up Emacs buffers in Vi state whenever this makes sense. @xref{Packages that Change Keymaps}, to find out when forcing Vi command state on a buffer may be counter-productive. -Even if your @file{.emacs} and @file{.vip} files do not contain any of the -above lines, you can still load Viper and enter Vi state by typing the +Even if your @file{.emacs} and @file{.viper} files do not contain any of the +above lines, you can still load Viper and enter Vi command state by typing the following from within Emacs: @lisp -M-x load-library RET viper RET M-x viper-mode @end lisp -@noindent -Ask your local Emacs administrator if this fails to work. - When Emacs first comes up, if you have not specified a file on the command line, it will show the @samp{*scratch*} buffer, in the @samp{Lisp Interaction} mode. After you invoke Viper, you can start @@ -378,7 +344,7 @@ @section States in Viper @kindex @kbd{C-z} -@kindex @kbd{ESC} +@kindex @key{ESC} @kindex @kbd{i} @cindex Emacs state @cindex Vi state @@ -390,7 +356,7 @@ @table @samp @item Emacs state -This is the mode plain vanilla Emacs is normally in. After you have loaded +This is the state plain vanilla Emacs is normally in. After you have loaded Viper, @kbd{C-z} will normally take you to Vi command state. Another @kbd{C-z} will take you back to Emacs state. This toggle key can be changed, @pxref{Customization} You can also type @kbd{M-x viper-mode} to @@ -407,14 +373,14 @@ @dots{}, will take you to Insert state. All Vi commands may be used in this mode. Most Ex commands can also be used. For a full list of Ex commands supported by Viper, type -@kbd{:} and then @kbd{TAB}. To get help on any issue, including the Ex +@kbd{:} and then @key{TAB}. To get help on any issue, including the Ex commands, type @kbd{:help}. This will invoke Viper Info (if it is installed). Then typing @kbd{i} will prompt you for a topic to search in the index. Note, to search for Ex commands in the index, you should start them with a ``@kbd{:}'', e.g., @kbd{:WW}. @item Insert state -Insert state is the Vi insertion mode. @kbd{ESC} will take you back to +Insert state is the Vi insertion mode. @key{ESC} will take you back to Vi state. Insert state editing can be done, including auto-indentation. By default, Viper disables Emacs keybindings in Insert state. @@ -423,7 +389,7 @@ boundary of a replacement region (usually designated via a @samp{$} sign), it will automatically change to Insert state. You do not have to worry about it. The key bindings remain practically the same as in Insert -state. If you type ESC, Viper will switch to Vi command mode, terminating the +state. If you type @key{ESC}, Viper will switch to Vi command mode, terminating the replacement state. @refill @end table @@ -547,17 +513,17 @@ @kindex @kbd{C-\} @cindex Meta key -Viper uses @kbd{ESC} as a switch between Insert and Vi states. Emacs uses -@kbd{ESC} for Meta. We need a Meta key to call the Meta key functions +Viper uses @key{ESC} as a switch between Insert and Vi states. Emacs uses +@key{ESC} for Meta. We need a Meta key to call the Meta key functions such as @kbd{M-x function name}. This role is played by the key @kbd{C-\}. Thus, to get @kbd{M-x}, you should type @kbd{C-\ x} (if the keyboard has no Meta key). This works both in the Vi state and the Insert state. -Alternatively, you can use @kbd{\ ESC} in Vi state to simulate the meta +Alternatively, you can use @kbd{\ @key{ESC}} in Vi state to simulate the meta key. -It is possible to use @kbd{ESC} as Meta, but then you cannot -press @kbd{ESC} multiple times in Vi state. @xref{Customization}, to find -out how to rebind ESC to be Meta.@refill +It is possible to use @key{ESC} as Meta, but then you cannot +press @key{ESC} multiple times in Vi state. @xref{Customization}, to find +out how to rebind @key{ESC} to be Meta.@refill @end table @noindent Other differences are mostly improvements. The ones you should know @@ -608,9 +574,9 @@ It is designed to minimize the need for deleting path names that Emacs provides in its prompts. (This is usually convenient, but occasionally the prompt may suggest a wrong path name for you.) If you see a prompt -@kbd{/usr/foo/} and you wish to edit the file @kbd{~/.vip}, you don't +@kbd{/usr/foo/} and you wish to edit the file @kbd{~/.viper}, you don't have to erase the prompt. Instead, simply continue typing what you -need. Emacs will interpret @kbd{/usr/foo/~/.vip} correctly. Similarly, +need. Emacs will interpret @kbd{/usr/foo/~/.viper} correctly. Similarly, if the prompt is @kbd{~/foo/} and you need to get to @kbd{/bar/file}, keep typing. Emacs interprets @kbd{~/foo//bar/} as @kbd{/bar/file}, since when it sees @samp{//}, it understands that @kbd{~/foo/} is to be discarded. @@ -625,7 +591,7 @@ windows). When applicable, Ex commands support file completion and history. This -means that by typing a partial file name and then @kbd{TAB}, Emacs will try +means that by typing a partial file name and then @key{TAB}, Emacs will try to complete the name or it will offer a menu of possible completions. This works similarly to Tcsh and extends the behavior of Csh. While Emacs is waiting for a file name, you can type @kbd{M-p} to get the previous file @@ -633,13 +599,13 @@ browse through the file history. Like file names, partially typed Ex commands can be completed by typing -@kbd{TAB}, and Viper keeps the history of Ex commands. After typing +@key{TAB}, and Viper keeps the history of Ex commands. After typing @kbd{:}, you can browse through the previously entered Ex commands by typing @kbd{M-p} and @kbd{M-n}. Viper tries to rationalize when it puts Ex commands on the history list. For instance, if you typed @kbd{:w! foo}, only @kbd{:w!} will be placed on the history list. This is because the last history element is the default that can be invoked simply by typing -@kbd{: RET}. If @kbd{:w! foo} were placed on the list, it would be all to +@kbd{: @key{RET}}. If @kbd{:w! foo} were placed on the list, it would be all to easy to override valuable data in another file. Reconstructing the full command, @kbd{:w! foo}, from the history is still not that hard, since Viper has a separate history for file names. By typing @kbd{: M-p}, you will get @@ -723,9 +689,10 @@ This state is entered through Vi replacement commands, such as @kbd{C}, @kbd{cw}, etc., or by typing @kbd{R}. In Replace state, Viper puts <R> in the mode line to let you know which state is in effect. If Replace state is -entered through @kbd{R}, Viper stays in that state until the user hits ESC. +entered through @kbd{R}, Viper stays in that state until the user hits +@key{ESC}. If this state is entered via the other replacement commands, then Replace -state is in effect until you hit @kbd{ESC} or until you cross the rightmost +state is in effect until you hit @key{ESC} or until you cross the rightmost boundary of the replacement region. In the latter case, Viper changes its state from Replace to Insert (which you will notice by the change in the mode line). @@ -738,7 +705,7 @@ the need to enable text selection and region-setting with the mouse.) The issue then arises as to what to do when the user -hits the ESC key. In Vi, this would cause the text between cursor and +hits the @key{ESC} key. In Vi, this would cause the text between cursor and the end of the replacement region to be deleted. But what if, as is possible in Viper, the cursor is not inside the replacement region? @@ -764,7 +731,7 @@ Erase line @item C-v Quote the following character -@item RET +@item @key{RET} Execute command @item C-g and C-] Emacs quit and abort keys. These may be necessary. @xref{Vi State}, for an @@ -783,7 +750,7 @@ Initially, the Minibuffer comes up in Insert state. Some users prefer plain Emacs bindings in the Minibuffer. To this end, set -@code{vip-vi-style-in-minibuffer} to @code{nil} in @file{.vip}. +@code{vip-vi-style-in-minibuffer} to @code{nil} in @file{.viper}. @xref{Customization}, to learn how to do this. When the Minibuffer changes Viper states, you will notice that the appearance @@ -817,8 +784,8 @@ last @kbd{!} command whichever file it was issued from. Typing @kbd{.} will repeat the last command from any file, and searches will repeat the last search. Ex commands can be repeated by typing -@kbd{:RET}.@refill -Note: in some rare cases, that @kbd{:RET} may do something dangerous. +@kbd{: @key{RET}}.@refill +Note: in some rare cases, that @kbd{: @key{RET}} may do something dangerous. However, usually its effect can be undone by typing @kbd{u}. @item Registers @cindex registers @@ -846,7 +813,7 @@ current directory). This directory is inserted in the Minibuffer once you type space after @kbd{:e, r}, etc. Viper also supports completion of file names and Ex -commands (@kbd{TAB}), and it keeps track of +commands (@key{TAB}), and it keeps track of command and file history (@kbd{M-p}, @kbd{M-n}). Absolute filenames are required less often in Viper. @@ -978,7 +945,7 @@ (@xref{Multiple Files in Viper}). In addition to the files, Emacs has buffers. These can be seen in the @kbd{:args} list and switched using @kbd{:next} if you type @kbd{:set ex-cycle-through-non-files t}, or -specify @code{(setq ex-cycle-through-non-files t)} in your @file{.vip} +specify @code{(setq ex-cycle-through-non-files t)} in your @file{.viper} file. @xref{Customization}, for details. @node Undo and Backups, History, Basics, Improvements over Vi @@ -1038,8 +1005,8 @@ simply type Return to execute. @item M-r and M-s To search backward and forward through the history. -@item RET -Type RET to accept a default (which is displayed in the prompt). +@item @key{RET} +Type @key{RET} to accept a default (which is displayed in the prompt). @end table The history of insertions can be perused by @@ -1071,7 +1038,7 @@ where @samp{register} is any character from @samp{a} through @samp{z}. Then you can execute this macro using @kbd{@@register}. It is, of course, possible to yank some text into a register and execute it using -@kbd{@@register}. Typing @kbd{@@@@}, @kbd{@@RET}, or @kbd{@@LF} will +@kbd{@@register}. Typing @kbd{@@@@}, @kbd{@@RET}, or @kbd{@@C-j} will execute the last macro that was executed using @kbd{@@register}.@refill Viper will automatically lowercase the register, so that pressing the @@ -1108,7 +1075,7 @@ @cindex completion -Completion is done when you type @kbd{TAB}. The Emacs completer does not +Completion is done when you type @key{TAB}. The Emacs completer does not grok wildcards in filenames. Once you type a wildcard, the completer will no longer work for that path. Remember that Emacs interprets a file name of the form @kbd{/foo//bar} as @kbd{/bar} and @kbd{/foo/~/bar} as @@ -1121,7 +1088,7 @@ @cindex word search Viper provides buffer search, the ability to search the buffer for a region -under the cursor. You have to turn this on in @file{.vip} either by calling +under the cursor. You have to turn this on in @file{.viper} either by calling @example (vip-buffer-search-enable) @@ -1172,7 +1139,7 @@ @end example @vindex @code{vip-search-face} @noindent -in @file{~/.vip}. If you want to change how patterns are highlighted, you +in @file{~/.viper}. If you want to change how patterns are highlighted, you will have to set the variable @code{vip-search-face} to some other face, such as @code{highlight}. If none of the existing faces fits the bill, you would have to create your own. Further details on faces can be found @@ -1198,7 +1165,7 @@ will search further back in the buffer, so that one could get @samp{Abbrevs} by repeating the keystroke, which appears earlier in the text. Emacs binds this to -@kbd{ESC /}, so you will have to find a key and bind the function +@kbd{@key{ESC} /}, so you will have to find a key and bind the function @code{dabbrev-expand} to that key. Facilities like this make Vi's @kbd{:ab} command obsolete. @@ -1209,8 +1176,8 @@ @cindex line editor motion Viper can be set free from the line--limited movements in Vi, such as @kbd{l} -refusing to move beyond the line, @kbd{ESC} moving one character back, -etc. These derive from Ex, which is a line editor. If your @file{.vip} +refusing to move beyond the line, @key{ESC} moving one character back, +etc. These derive from Ex, which is a line editor. If your @file{.viper} contains @example @@ -1229,24 +1196,24 @@ The word-movement commands @kbd{w}, @kbd{e}, etc., and the associated deletion/yanking commands, @kbd{dw}, @kbd{yw}, etc., can be made to understand Emacs syntax tables. If the variable -@code{vip-syntax-preference} is set to @code{'strict-vi} (the default) then +@code{vip-syntax-preference} is set to @code{strict-vi} (the default) then the meaning of @emph{word} is the same as in -Vi. However, if the value is @code{'reformed-vi} then the alphanumeric +Vi. However, if the value is @code{reformed-vi} then the alphanumeric symbols will be those specified by the current Emacs syntax table (which may be different for different major modes) plus the underscore symbol -@code{_}. The user can also specify the value @code{'emacs}, which would +@code{_}. The user can also specify the value @code{emacs}, which would make Viper use exactly the Emacs notion of word. In particular, the underscore may not be part of a word. Finally, if -@code{vip-syntax-preference} is set to @code{'extended}, Viper words would +@code{vip-syntax-preference} is set to @code{extended}, Viper words would consist of characters that are classified as alphanumeric @emph{or} as parts of symbols. This is convenient for writing programs and in many other situations. @code{vip-syntax-preference} is a local variable, so it can have different values for different major modes. For instance, in programming modes it can -have the value @code{'extended}. In text modes where words contain special +have the value @code{extended}. In text modes where words contain special characters, such as European (non-English) letters, Cyrillic letters, etc., -the value can be @code{'reformed-vi} or @code{'emacs}. +the value can be @code{reformed-vi} or @code{emacs}. Changes to @code{vip-syntax-preference} should be done in the hooks to various major modes. Furthermore, for these changes to take effect, you @@ -1284,14 +1251,14 @@ will be in Vi state again. Except for novice users, @kbd{C-c} is also set to temporarily escape to Emacs and execute a command from the current major mode. -@kbd{ESC} will do the same, if +@key{ESC} will do the same, if you configure @key{ESC} as Meta by setting @code{vip-no-multiple-ESC} to nil -in @file{.vip}. @xref{Customization}. @kbd{C-\} +in @file{.viper}. @xref{Customization}. @kbd{C-\} in Insert or Vi states will make Emacs think @kbd{Meta} has been hit.@refill @item \ @kindex @kbd{\} -Escape to Emacs to execute a single Emacs command. For instance, @kbd{\ -ESC} will act like a Meta key. +Escape to Emacs to execute a single Emacs command. For instance, +@kbd{\ @key{ESC}} will act like a Meta key. @item Q @kindex @kbd{Q} @cindex query replace @@ -1322,12 +1289,12 @@ @item # c @kindex @kbd{#c<move>} @cindex changing case -Change upper case characters in the region to lower case +Change upper-case characters in the region to lower-case (@code{downcase-region}). Emacs command @kbd{M-l} does the same for words. @item # C @kindex @kbd{#C<move>} -Change lower case characters in the region to upper case. For instance, +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}). Emacs command @kbd{M-u} does the same for words. @@ -1546,9 +1513,9 @@ @itemize @bullet @item @cindex initialization -@cindex .vip -Elisp code in a @file{.vip} file in your home directory. Viper -loads @file{.vip} just before it does the binding for mode +@cindex .viper +Elisp code in a @file{.viper} file in your home directory. Viper +loads @file{.viper} just before it does the binding for mode hooks. This is the recommended method. @item @cindex .emacs @@ -1582,25 +1549,25 @@ @code{t} and @code{nil} represent ``true'' and ``false'' in Lisp). Viper supports both the abbreviated Vi variable names and their full -names. Variable completion is done on full names only. @kbd{TAB} and -@kbd{SPC} complete +names. Variable completion is done on full names only. @key{TAB} and +@key{SPC} complete variable names. Typing `=' will complete the name and then will prompt for -a value, if applicable. For instance, @kbd{:se auSPC} will complete the -command to @kbd{:set autoindent}; @kbd{:se taSPC} will complete the command +a value, if applicable. For instance, @kbd{:se au @key{SPC}} will complete the +command to @kbd{:set autoindent}; @kbd{:se ta @key{SPC}} will complete the command and prompt further like this: @kbd{:set tabstop = }. -However, typing @kbd{:se tsSPC} will produce a ``No match'' message +However, typing @kbd{:se ts @key{SPC}} will produce a ``No match'' message because @kbd{ts} is an abbreviation for @kbd{tabstop} and Viper supports -completion on full names only. However, you can still hit @kbd{RET} +completion on full names only. However, you can still hit @key{RET} or @kbd{=}, which will complete the command like this: @kbd{:set ts = } and Viper will be waiting for you to type a value for the tabstop variable. -To get the full list of Vi variables, type @kbd{:se SPC TAB}. +To get the full list of Vi variables, type @kbd{:se @key{SPC} @key{TAB}}. @table @code @item vip-auto-indent nil @itemx :se ai (:se autoindent) -@itemx :se gai (:se global-autoindent) +@itemx :se ai-g (:se autoindent-global) If @code{t}, enable auto indentation. -by @kbd{RET}, @kbd{o} or @kbd{O} command. +by @key{RET}, @kbd{o} or @kbd{O} command. @code{vip-auto-indent} is a local variable. To change the value globally, use @code{setq-default}. It may be useful for certain major modes to have their @@ -1612,7 +1579,7 @@ buffer only; @kbd{:se gai} does the same globally. @item vip-electric-mode t If not @code{nil}, auto-indentation becomes electric, which means that -@kbd{RET}, @kbd{O}, and @kbd{o} indent cursor according to the current +@key{RET}, @kbd{O}, and @kbd{o} indent cursor according to the current major mode. In the future, this variable may control additional electric features. @@ -1637,7 +1604,7 @@ Show matching parens by blinking cursor. @item tab-width t (default setting via @code{setq-default}) @itemx :se ts=value (:se tabstop=value) -@itemx :se gts=value (:se global-tabstop=value) +@itemx :se ts-g=value (:se tabstop-global=value) @code{tab-width} is a local variable that controls the width of the tab stops. To change the value globally, use @code{setq-default}; for local settings, use @code{setq}. @@ -1650,14 +1617,14 @@ for all buffers where the tab is not yet set locally, including the new buffers. -Note that typing @kbd{TAB} normally +Note that typing @key{TAB} normally doesn't insert the tab, since this key is usually bound to a text-formatting function, @code{indent-for-tab-command} (which facilitates programming and document writing). Instead, the tab is inserted via the command @code{vip-insert-tab}, which is bound to @kbd{S-tab} (shift + tab). -On some non-windowing terminals, Shift doesn't modify the @kbd{TAB} key, so -@kbd{S-tab} behaves as if it were @kbd{TAB}. In such a case, you will have +On some non-windowing terminals, Shift doesn't modify the @key{TAB} key, so +@kbd{S-tab} behaves as if it were @key{TAB}. In such a case, you will have to bind @code{vip-insert-tab} to some other convenient key. @item vip-shift-width 8 @@ -1682,34 +1649,38 @@ insert mode when you type text in the Minibuffer; if @code{nil}, typing in the Minibuffer feels like plain Emacs. @item vip-no-multiple-ESC t -If you set this to @code{nil}, you can use @kbd{ESC} as Meta in Vi state. +If you set this to @code{nil}, you can use @key{ESC} as Meta in Vi state. Normally, this is not necessary, since graphical displays have separate Meta keys (usually on each side of the space bar). On a dumb terminal, Viper sets this variable to @code{twice}, which is almost like @code{nil}, except -that double @kbd{ESC} beeps. This, too, lets ESC to be used as a Meta. +that double @key{ESC} beeps. This, too, lets @key{ESC} to be used as a Meta. @item vip-keysequence-delay 140 Escape sequences separated by this much delay are interpreted as command, -ignoring the special meaning of ESC in VI. The default is suitable for most -terminals. However, if your terminal is extremely slow, you -might want to increase this slightly. You will know if your terminal is -slow if the ESC key sequences emitted by the arrow keys are interpreted as -separately typed characters (and thus the arrow keys won't work). -Making this value too large will slow you down, so exercise restraint. +ignoring the special meaning of @key{ESC} in VI. The default is suitable +for most terminals. However, if your terminal is extremely slow, you might +want to increase this slightly. You will know if your terminal is slow if +the @key{ESC} key sequences emitted by the arrow keys are interpreted as +separately typed characters (and thus the arrow keys won't work). Making +this value too large will slow you down, so exercise restraint. @item vip-ex-style-motion t Set this to @code{nil}, if you want @kbd{l,h} to cross lines, etc. @xref{Movement and Markers}, for more info. @item vip-ex-style-editing-in-insert t -Set this to to @code{nil}, if you want @kbd{ESC} to not move back and +Set this to to @code{nil}, if you want @key{ESC} to not move back and @kbd{C-h} to not stop at the beginning of a line in Insert state. -@item vip-always t -Leave it to Viper to decide when a buffer must be brought up in Vi state, +@item viper-always t +@code{t} means: leave it to Viper to decide when a buffer must be brought +up in Vi state, Insert state, or Emacs state. This heuristics works well in virtually all -cases. -This option must be -set before Viper is loaded or in the @file{.vip} file. -@item vip-custom-file-name "~/.vip" -Change this if you want. Must be set in @file{.emacs} (not @file{.vip}!) +cases. @code{nil} means you either has to invoke @code{viper-mode} manually +for each buffer (or you can add @code{viper-mode} to the appropriate major mode +hooks using @code{vip-load-hook}). + +This option must be set in the file @file{~/.viper}. +@item vip-custom-file-name "~/.viper" +File used for Viper-specific customization. +Change this setting, if you want. Must be set in @file{.emacs} (not @file{.viper}!) before Viper is loaded. Note that you have to set it as a string inside double quotes. @item vip-spell-function 'ispell-region @@ -1768,7 +1739,7 @@ @code{vip-repeat-from-history}, which checks the second key by which it is invoked to see which of the previous commands to invoke. Viper binds @kbd{f12 1} and @kbd{f12 2} only, -but the user can bind more in @file{~/.vip}. @xref{Vi Macros}, for how to do +but the user can bind more in @file{~/.viper}. @xref{Vi Macros}, for how to do this. @item vip-keep-point-on-undo nil If not @code{nil}, Viper tries to not move point when undoing commands. @@ -1777,7 +1748,7 @@ then point will be moved to the place where the change took place. Set it to @code{t} and see if you like it better. @item vip-delete-backwards-in-replace nil -If not @code{nil}, DEL key will delete characters while moving the cursor +If not @code{nil}, @key{DEL} key will delete characters while moving the cursor backwards. If @code{nil}, the cursor will move backwards without deleting anything. @item vip-replace-overlay-face 'vip-replace-overlay-face @@ -1837,7 +1808,7 @@ replacement regions (and multi-line replacement regions are deleted). @item vip-toggle-key "\C-z" Specifies the key used to switch from Emacs to Vi and back. -Must be set in @file{.vip} or prior to loading Viper. This variable can't be +Must be set in @file{.viper} or prior to loading Viper. This variable can't be changed interactively after Viper is loaded. In Insert state, this key acts as a temporary escape to Vi state, i.e., it @@ -1845,7 +1816,7 @@ were typed in Vi state. @item vip-ESC-key "\e" Specifies the key used to escape from Insert/Replace states to Vi. -Must be set in @file{.vip} or prior to loading Viper. This variable cannot be +Must be set in @file{.viper} or prior to loading Viper. This variable cannot be changed interactively after Viper is loaded. @item vip-buffer-search-char nil Key used for buffer search. @xref{Viper Specials}, for details. @@ -1874,7 +1845,7 @@ @noindent You can reset some of these constants in Viper with the Ex command @kbd{:set} (when so indicated in the table). Or you -can include a line like this in your @file{.vip} file: +can include a line like this in your @file{.viper} file: @example (setq vip-case-fold-search t) @end example @@ -1892,7 +1863,7 @@ @vindex @code{vip-want-ctl-h-help} @vindex @code{vip-vi-style-in-minibuffer} @vindex @code{vip-no-multiple-ESC} -@vindex @code{vip-always} +@vindex @code{viper-always} @vindex @code{vip-keysequence-delay} @vindex @code{vip-ex-style-motion} @vindex @code{vip-ex-style-editing-in-insert} @@ -1987,7 +1958,7 @@ If you want to bind a key, say @kbd{C-v}, to the function that scrolls page down and to make @kbd{0} display information on the current buffer, -putting this in @file{.vip} will do the trick in Vi state: +putting this in @file{.viper} will do the trick in Vi state: @example (define-key vip-vi-global-user-map "\C-v" 'scroll-down) @end example @@ -2035,11 +2006,11 @@ @end example @noindent -in @file{~/.vip}. To do the same in Vi and Insert states, one should use +in @file{~/.viper}. To do the same in Vi and Insert states, one should use @code{vi-state} and @code{insert-state}. Changes in Insert state are also in effect in Replace state. For instance, suppose that the user wants to use @kbd{dd} in Vi state under Dired mode to delete files, @kbd{u} to unmark -files, etc. The following code in @file{~/.vip} will then do the job: +files, etc. The following code in @file{~/.viper} will then do the job: @example (setq my-dired-modifier-map (make-sparse-keymap)) @@ -2075,7 +2046,7 @@ avoid this, one should add @code{vip-change-state-to-emacs} to an appropriate hook of that major mode. (Check the function @code{vip-set-hooks} in @file{viper.el} for examples.) However, if you -have set @code{vip-always} to @code{t}, chances are that you won't need to +have set @code{viper-always} to @code{t}, chances are that you won't need to perform the above procedure, because Viper will take care of most useful defaults. @@ -2122,13 +2093,13 @@ You can also use @code{vip-add-local-keys} to set per buffer bindings in Insert state and Emacs state by passing as a parameter the -symbols @code{'insert-state} and @code{'emacs-state}, respectively. +symbols @code{insert-state} and @code{emacs-state}, respectively. As with global bindings, customized local bindings done to Emacs state are not inherited by Insert state. On rare occasions, local keys may be added by mistake. Usually this is done indirectly, by invoking a major mode that adds local keys (e.g., -@code{shell-mode} redefines @kbd{RET}). In such a case, exiting the wrong +@code{shell-mode} redefines @key{RET}). In such a case, exiting the wrong major mode won't rid you from unwanted local keys, since these keys are local to Viper state and the current buffer, not to the major mode. In such situations, the remedy is to type @kbd{M-x vip-zap-local-keys}. @@ -2155,8 +2126,8 @@ (unless you explicitly prohibit them by setting @code{vip-want-emacs-keys-in-vi} and @code{vip-want-emacs-keys-in-insert} to @code{nil}). -If @code{vip-always} is set to @code{t}, Viper will try to bring each buffer -in the a Viper state that is most appropriate for that buffer. +If @code{viper-always} is set to @code{t}, Viper will try to bring each buffer +in the Viper state that is most appropriate for that buffer. Usually, this would be the Vi state, but sometimes it could be the Insert state or the Emacs state. @@ -2166,33 +2137,33 @@ typically do not bind such keys. Instead, they use key sequences that start with @kbd{C-x} and @kbd{C-c}. This is why it was so important for us to free up @kbd{C-x} and @kbd{C-c}. -It is common for language-specific major modes to bind @kbd{TAB} and -@kbd{LFD} (the line feed) keys to various formatting functions. This is +It is common for language-specific major modes to bind @key{TAB} and +@kbd{C-j} (the line feed) keys to various formatting functions. This is extremely useful, but may require some getting used to for a Vi user. If you decide that this feature is not for you, you can re-bind these keys as explained earlier (@xref{Customization}). -Binding for @kbd{TAB} is one of the most unusual aspects of Viper for many -novice users. In Emacs, @kbd{TAB} is used to format text and programs, and -is extremely useful. For instance, hitting @kbd{TAB} causes the current +Binding for @key{TAB} is one of the most unusual aspects of Viper for many +novice users. In Emacs, @key{TAB} is used to format text and programs, and +is extremely useful. For instance, hitting @key{TAB} causes the current line to be re-indented in accordance with the context. In programming, this is very important, since improper automatic indentation would immediately alert the programmer to a possible error. For instance, if a @kbd{)} or a @kbd{"} is missing somewhere above the current -line, @kbd{TAB} is likely to mis-indent the line. +line, @key{TAB} is likely to mis-indent the line. For this reason, Viper doesn't change the standard Emacs binding of -@kbd{TAB}, thereby sacrificing Vi compatibility +@key{TAB}, thereby sacrificing Vi compatibility (except for users at level 1). Instead, in Viper, the key -@kbd{S-tab} (shift+ tab) is chosen to emulate Vi's @kbd{TAB}. +@kbd{S-tab} (shift+ tab) is chosen to emulate Vi's @key{TAB}. We should note that on some non-windowing terminals, Shift doesn't modify -the @kbd{TAB} key, so @kbd{S-tab} behaves as if it were @kbd{TAB}. In such +the @key{TAB} key, so @kbd{S-tab} behaves as if it were @key{TAB}. In such a case, you will have to bind @code{vip-insert-tab} to some other convenient key. Some packages, notably Dired, Gnus, Info, etc., attach special meaning to -common keys like @kbd{SPC}, @kbd{x}, @kbd{d}, @kbd{v}, and others. This +common keys like @key{SPC}, @kbd{x}, @kbd{d}, @kbd{v}, and others. This means that Vi command state is inappropriate for working with these packages. Fortunately, these modes operate on read-only buffers and are designed not for editing files, but for special-purpose browsing, reading @@ -2210,8 +2181,8 @@ It is also possible to harness some major modes, even though they may bind common keys to specialized commands. Harnessing can make sense for modes that bind only a small number of common keys. For instance, if -@code{vip-always} is set to @code{t} in your @file{~/.vip} file, Viper will -harness the Shell mode by changing the bindings for @kbd{C-m} and @kbd{C-d} +@code{viper-always} is set to @code{t} in your @file{~/.viper} file, Viper will +harness Shell mode by changing the bindings for @kbd{C-m} and @kbd{C-d} using @code{vip-add-local-keys} described in section on customization (@xref{Customization}). In general, there is no single recipe for harnessing modes. It can be as simple as adding the function @@ -2221,10 +2192,10 @@ Conversely, it may be the case that most of the major modes harnessed by @code{vip-set-hooks} function fit your working style, except one or two -cases. In this case, you may still be able to set @code{vip-always} to +cases. In this case, you may still be able to set @code{viper-always} to @code{t} and then remove a hook that forces Vi command state. For instance, to unharness @code{lisp-interaction-mode}, you can put the following line -in your @file{.emacs} (not @code{.vip}!) file after @code{(require 'viper)}: +in your @file{.emacs} (not @code{.viper}!) file after @code{(require 'viper)}: @lisp (remove-hook 'lisp-interaction-mode-hook 'viper-mode) @end lisp @@ -2236,7 +2207,7 @@ several such minor modes and takes care of them, so that the above trick is usually not necessary. If you find that some minor mode, e.g., @code{nasty-mode.el} interferes with Viper, putting the following in -@file{.vip} should fix the problem: +@file{.viper} should fix the problem: @lisp (vip-harness-minor-mode "nasty-mode") @end lisp @@ -2259,7 +2230,7 @@ @vindex @code{vip-want-emacs-keys-in-vi} @vindex @code{vip-want-emacs-keys-in-insert} -@vindex @code{vip-always} +@vindex @code{viper-always} @findex @code{vip-set-hooks} @findex @code{viper-mode} @findex @code{vip-harness-minor-mode} @@ -2281,7 +2252,7 @@ @item vip-buffer-search-char nil Enable buffer search. Explicit call to @code{vip-buffer-search-enable} sets @code{vip-buffer-search-char} to @kbd{g}. Alternatively, the user can -set @code{vip-buffer-search-char} in @file{.vip} to a key sequence +set @code{vip-buffer-search-char} in @file{.viper} to a key sequence to be used for buffer search. There is no need to call @code{vip-buffer-search-enable} in that case. @findex @code{vip-buffer-search-enable} @@ -2305,8 +2276,8 @@ second @kbd{/} doesn't follow quickly enough, then Viper will issue the usual prompt @kbd{/} and will wait for input, as usual in Vi. If you don't like this behavior, you can ``unrecord'' these macros in your -@file{~/.vip} file. For instance, if you don't like the above feature, put -this in @file{~/.vip}: +@file{~/.viper} file. For instance, if you don't like the above feature, put +this in @file{~/.viper}: @example (vip-set-vi-search-style-macros 'undefine) @end example @@ -2362,7 +2333,8 @@ try these suffixes in the order listed and will check if the corresponding file exists. -For instance, if completion stopped at `paper.' and the user typed RET, +For instance, if completion stopped at `paper.' and the user typed +@key{RET}, then Viper will check if the files `paper.', `paper.tex', `paper.c', etc., exist. It will take the first such file. If no file exists, Viper will give a chance to complete the file name by typing the appropriate suffix. If `paper.' was @@ -2384,7 +2356,7 @@ in succession will undo the previous insertion from the ring and insert the next item on the ring. If a larger ring size is needed, change the value of the above -variable in the @file{~/.vip} file. +variable in the @file{~/.viper} file. Since typing these sequences of keys may be tedious, it is suggested that the user should bind a function key, such as @kbd{f31}, as follows: @@ -2459,9 +2431,9 @@ (copy-face 'default 'vip-minibuffer-insert-face) (copy-face 'default 'vip-minibuffer-emacs-face) @end example -in the @file{~/.vip} file. However, in that case, the user will not have any +in the @file{~/.viper} file. However, in that case, the user will not have any indication of the current Viper state in the minibuffer. (This is important -if the user accidentally switches to another Viper state by typing @kbd{ESC} or +if the user accidentally switches to another Viper state by typing @key{ESC} or @kbd{C-z}). @end table @@ -2695,7 +2667,7 @@ not just to printable keys. For instance, one can define a macro that will be invoked by hitting @kbd{f3} then @kbd{f2} function keys. (The keys @kbd{delete} and @kbd{backspace} are excluded; also, a macro invocation -sequence can't start with ESC. Some other keys, such as @kbd{f1} and +sequence can't start with @key{ESC}. Some other keys, such as @kbd{f1} and @kbd{help}, can't be bound to macros under Emacs (not XEmacs), since they are bound in @code{key-translation-map}, which overrides any other binding the user gives to keys. In general, keys that have a binding in @@ -2719,7 +2691,7 @@ When the user finishes defining a macro (which is done by typing @kbd{C-x)} --- a departure from Vi), you will be asked whether you want this macro to be global, mode-specific, or buffer-specific. You will also be -given a chance to save the macro in your @file{~/.vip} file. +given a chance to save the macro in your @file{~/.viper} file. This is the easiest way to save a macro and make it permanently available. If you work your startup files with bare hands, here is how Viper saves the above macro so that it will be @@ -2749,7 +2721,7 @@ instance, holding Meta and Control and pressing @kbd{f4} is represented as @kbd{(control meta f4)}. If all members of a vectors are printable characters (or sequences, such as -@kbd{\e}, @kbd{\t}, for ESC and TAB), then they can also be represented as +@kbd{\e}, @kbd{\t}, for @key{ESC} and @key{TAB}), then they can also be represented as strings: @example @@ -2768,14 +2740,14 @@ For convenience, Viper also lets you define Vi-style macros in its Emacs state. There is no Ex command, like @kbd{:map} and @kbd{:map!} for doing -this, but the user can include such a macro in the @file{~/.vip} file. The +this, but the user can include such a macro in the @file{~/.viper} file. The only thing is that the @code{vip-record-kbd-macro} command should specify -@code{'emacs-state} instead of @code{'vi-state} or @code{'insert-state}. +@code{emacs-state} instead of @code{vi-state} or @code{insert-state}. The user can get rid of a macro either by using the Ex commands @kbd{:unmap} and @kbd{:unmap!} or by issuing a call to @code{vip-unrecord-kbd-macro}. The latter is more powerful, since it can delete macros even in -@code{'emacs-state}. However, @code{vip-unrecord-kbd-macro} is usually +@code{emacs-state}. However, @code{vip-unrecord-kbd-macro} is usually needed only when the user needs to get rid of the macros that are already predefined in Viper. The syntax is: @@ -2784,8 +2756,8 @@ (vip-unrecord-kbd-macro macro state) @end example @noindent -The second argument must be @code{'vi-state}, @code{'insert-state}, or -@code{'emacs-state}. The first argument is a name of a macro. To avoid +The second argument must be @code{vi-state}, @code{insert-state}, or +@code{emacs-state}. The first argument is a name of a macro. To avoid mistakes in specifying names of existing macros, type @kbd{M-x vip-describe-kbd-macros} and use a name from the list displayed by this command. @@ -2826,14 +2798,14 @@ other function. Emacs doesn't allow the user to do that, but Viper does this through its keyboard macro facility. To do this, type @kbd{:map } first. When you are asked to enter a macro name, hit f13 twice, followed by -RET or SPC. +@key{RET} or @key{SPC}. Emacs will now start the mapping process by actually executing Vi and Emacs commands, so that you could see what will happen each time the macro is executed. Suppose now we wanted to bind the key sequence @kbd{f13 f13} to the command @code{eval-last-sexp}. To accomplish this, we can type @kbd{M-x eval-last-sexp} followed by @kbd{C-x )}. -If you answer positively to Viper's offer to save this macro in @file{~/.vip} +If you answer positively to Viper's offer to save this macro in @file{~/.viper} for future uses, the following will be inserted in that file: @example @@ -2882,7 +2854,7 @@ the actual key @kbd{f6} if it is to be part of a macro name; you do @emph{not} write `f 6'. When entering keys, Viper displays them as strings or vectors (e.g., "abc" or [f6 f7 a]). The same holds for unmapping. Hitting -TAB while typing a macro name in the @kbd{:unmap} or @kbd{:unmap!} command +@key{TAB} while typing a macro name in the @kbd{:unmap} or @kbd{:unmap!} command will cause name completion. Completions are displayed as strings or vectors. However, as before, you don't actually type ``"'', ``['', or ``]'' that appear in the completions. These are meta-symbols that indicate whether @@ -2905,7 +2877,7 @@ @code{vip-fast-keyseq-timeout}, which defaults to 200 milliseconds. @vindex @code{vip-fast-keyseq-timeout} -For the most part, Viper macros defined in @file{~/.vip} can be shared +For the most part, Viper macros defined in @file{~/.viper} can be shared between Emacs, XEmacs, and X and TTY modes. However, macros defined via function keys may need separate definitions when XEmacs and Emacs have different names for the same keyboard key. For instance, the `Page Up' key @@ -2925,7 +2897,1299 @@ currently defined. To see all macros along with their definitions, type @kbd{M-x vip-describe-kbd-macros}. -@include viper-cmd.texi +@node Commands,,Customization,Top,Top +@chapter Commands + +This section is a semi-automatically bowdlerized version of the Vi +reference created by @* @samp{maart@@cs.vu.nl} and others. It can be +found on the Vi archives. This reference has been adapted for Viper.@refill + +@menu +* Groundwork:: Textual Conventions and Viper basics +* Text Handling:: Moving, Editing, Undoing. +* Display:: Scrolling. +* File and Buffer Handling:: Editing, Writing and Quitting. +* Mapping:: Mapping Keys, Keyboard Macros +* Shell Commands:: Accessing Shell Commands, Processing Text +* Options:: Ex options, the @kbd{:set} commands +* Emacs Related Commands:: Meta Keys, Windows +* Mouse-bound Commands:: Search and insertion of text +@end menu + +@node Groundwork, Text Handling, Commands, Commands +@comment node-name, next, previous, up +@section Groundwork + +The VI command set is based on the idea of combining motion commands +with other commands. The motion command is used as a text region +specifier for other commands. +We classify motion commands into @dfn{point commands} and +@dfn{line commands}.@refill + +@cindex point commands + +The point commands are: + +@quotation +@kbd{h}, @kbd{l}, @kbd{0}, @kbd{$}, @kbd{w}, @kbd{W}, @kbd{b}, @kbd{B}, +@kbd{e}, @kbd{E}, @kbd{(}, @kbd{)}, @kbd{/}, @kbd{?}, @kbd{`}, @kbd{f}, +@kbd{F}, @kbd{t}, @kbd{T}, @kbd{%}, @kbd{;}, @kbd{,}, @kbd{^} +@end quotation + +@cindex line commands + +The line commands are: + +@quotation +@kbd{j}, @kbd{k}, @kbd{+}, @kbd{-}, @kbd{H}, @kbd{M}, @kbd{L}, @kbd{@{}, +@kbd{@}}, @kbd{G}, @kbd{'}, @kbd{[[}, @kbd{]]}, @kbd{[]} +@end quotation +@noindent + +Text Deletion Commands (@xref{Deleting Text}), Change commands +(@xref{Changing Text}), even Shell Commands (@xref{Shell Commands}) +use these commands to describe a region of text to operate on. + +@cindex r and R region specifiers + +Viper adds two region descriptors, @kbd{r} and @kbd{R}. These describe +the Emacs regions (@xref{Basics}), but they are not movement commands. + +The command description uses angle brackets @samp{<>} to indicate +metasyntactic variables, since the normal conventions of using simple +text can be confusing with Viper where the commands themselves are +characters. Watch out where @kbd{<} shift commands and @kbd{<count>} are +mentioned together!!! + +@kindex <move> +@kindex <a-z> +@kindex <address> +@cindex <move> +@cindex <a-z> +@cindex <address> +@cindex movements + +@samp{<move>} refers to the above movement commands, and @samp{<a-z>} +refers to registers or textmarkers from @samp{a} to @samp{z}. Note +that the @samp{<move>} is described by full move commands, that is to +say they will take counts, and otherwise behave like normal move commands. +@cindex Ex addresses +@samp{<address>} refers to Ex line addresses, which include + +@table @kbd +@item . <No address> +Current line +@item .+n .-n +Add or subtract for current line +@item number +Actual line number, use @kbd{.=} to get the line number +@item '<a-z> +Textmarker +@item $ +Last line +@item x,y +Where x and y are one of the above +@item % +@cindex % (Ex address) +For the whole file, same as (1,$). +@item /pat/ +@item ?pat? +Next or previous line with pattern pat +@end table + +@cindex % (Current file) +Note that @samp{%} is used in Ex commands to mean current file. If you +want a @samp{%} in your command, it must be escaped as @samp{\%}. +@cindex # (Previous file) +Similarly, @samp{#} expands to the previous file. The previous file is +the first file in @kbd{:args} listing. This defaults to previous window +in the VI sense if you have one window only. + +@kindex <args> +@kindex <cmd> +@cindex <args> +@cindex <cmd> +@noindent +Others like @samp{<args> -- arguments}, @samp{<cmd> -- command} etc. +should be fairly obvious. + +@noindent +Common characters referred to include: + +@table @kbd +@item <sp> +Space +@item <ht> +Tab +@item <lf> +Linefeed +@item <esc> +Escape +@item <cr> +Return, Enter +@end table +@cindex <cr> +@cindex <esc> +@cindex <lf> +@cindex <ht> +@cindex <sp> + +@cindex words +@cindex WORDS +@cindex char +@cindex CHAR + +We also use @samp{word} for alphanumeric/non-alphanumeric words, and +@samp{WORD} for whitespace delimited words. @samp{char} refers to any +ASCII character, @samp{CHAR} to non-whitespace character. +Brackets @samp{[]} indicate optional parameters; @samp{<count>} also +optional, usually defaulting to 1. Brackets are elided for +@samp{<count>} to eschew obfuscation. + +Viper's idea of Vi's words is slightly different from Vi. First, Viper +words understand Emacs symbol tables. Therefore, all symbols declared to be +alphanumeric in a symbol table can automatically be made part of the Viper +word. This is useful when, for instance, editing text containing European, +Cyrillic, etc., letters. + +Second, Viper lets you depart from Vi's idea of a word by changing the +value of @code{vip-syntax-preference}. By default, this variable is set to +@code{strict-vi}, which means that alphanumeric symbols are exactly as +in Vi. +However, if the value is @code{reformed-vi} then alphanumeric +symbols will be those specified by the current Emacs syntax table (which +may be different for different major modes) plus the underscore symbol +@code{_}. The user can also specify the value @code{emacs}, which would +make Viper use exactly the Emacs notion of word. In particular, the +underscore may not be part of a word. Finally, if +@code{vip-syntax-preference} is set to @code{extended}, Viper words would +consist of characters that are classified as alphanumeric @emph{or} as +parts of symbols. This is convenient for writing programs and in many other +situations. + +@vindex @code{vip-syntax-preference} +@cindex syntax table + +@code{vip-syntax-preference} is a local variable, so it can have different +values for different major modes. For instance, in programming modes it can +have the value @code{extended}. In text modes where words contain special +characters, such as European (non-English) letters, Cyrillic letters, etc., +the value can be @code{reformed-vi} or @code{emacs}. + +Changes to @code{vip-syntax-preference} should be done in the hooks to +various major modes. Furthermore, for these changes to take effect, you +should execute @code{(vip-update-alphanumeric-class)} right after changing +the value of @code{vip-syntax-preference}. + +The above discussion concerns only the movement commands. In regular +expressions, words remain the same as in Emacs. That is, the expressions +@code{\w}, @code{\>}, @code{\<}, etc., use Emacs' idea of what is a word, +and they don't look into the value of variable +@code{vip-syntax-preference}. This is because Viper doesn't change syntax +tables in order to not thwart the various major modes that set these +tables. + +The usual Emacs convention is used to indicate Control Characters, i.e +C-h for Control-h. @emph{Do not confuse this to mean the separate +characters C - h!!!} The @kbd{^} is itself, never used to indicate a +Control character. + +@node Text Handling, Display, Groundwork, Commands +@section Text Handling + +@menu +* Move Commands:: Moving, Searching +* Marking:: Textmarkers in Viper and the Emacs Mark. +* Appending Text:: Text insertion, Shifting, Putting +* Editing in Insert State:: Autoindent, Quoting etc. +* Deleting Text:: Deleting +* Changing Text:: Changing, Replacement, Joining +* Search and Replace:: Searches, Query Replace, Pattern Commands +* Yanking:: Yanking, Viewing Registers +* Undoing:: Multiple Undo, Backups +@end menu + +@node Move Commands,Marking,,Text Handling +@subsection Move Commands + +@cindex movement commands +@cindex searching +@cindex textmarkers +@cindex markers +@cindex column movement +@cindex paragraphs +@cindex headings +@cindex sections +@cindex sentences +@cindex matching parens +@cindex paren matching + +@table @kbd +@item <count> h C-h +<count> chars to the left. +@item <count> j <lf> C-n +<count> lines downward. +@item <count> l <sp> +<count> chars to the right. +@item <count> k C-p +<count> lines upward. +@item <count> $ +To the end of line <count> from the cursor. +@item <count> ^ +To the first CHAR <count> - 1 lines lower. +@item <count> - +To the first CHAR <count> lines higher. +@item <count> + <cr> +To the first CHAR <count> lines lower. +@item 0 +To the first char of the line. +@item <count> | +To column <count> +@item <count> f<char> +<count> <char>s to the right (find). +@item <count> t<char> +Till before <count> <char>s to the right. +@item <count> F<char> +<count> <char>s to the left. +@item <count> T<char> +Till after <count> <char>s to the left. +@item <count> ; +Repeat latest @kbd{f t F T} <count> times. +@item <count> , +Repeat latest @kbd{f t F T} +<count> times in opposite direction. +@item <count> w +<count> words forward. +@item <count> W +<count> WORDS forward. +@item <count> b +<count> words backward. +@item <count> B +<count> WORDS backward. +@item <count> e +To the end of word <count> forward. +@item <count> E +To the end of WORD <count> forward. +@item <count> G +Go to line <count> (default end-of-file). +@item <count> H +To line <count> from top of the screen (home). +@item <count> L +To line <count> from bottom of the screen (last). +@item M +To the middle line of the screen. +@item <count> ) +<count> sentences forward. +@item <count> ( +<count> sentences backward. +@item <count> @} +<count> paragraphs forward. +@item <count> @{ +<count> paragraphs backward. +@item <count> ]] +To the <count>th heading. +@item <count> [[ +To the <count>th previous heading. +@item <count> [] +To the end of <count>th heading. +@item m<a-z> +Mark the cursor position with a letter. +@item `<a-z> +To the mark. +@item '<a-z> +To the first CHAR of the line with the mark. +@item [<a-z> +Show contents of textmarker. +@item ]<a-z> +Show contents of register. +@item `` +To the cursor position before the latest absolute +jump (of which are examples @kbd{/} and @kbd{G}). +@item '' +To the first CHAR of the line on which the cursor +was placed before the latest absolute jump. +@item <count> /<string> +To the <count>th occurrence of <string>. +@item <count> /<cr> +To the <count>th occurrence of <string> from previous @kbd{/ or ?}. +@item <count> ?<string> +To the <count>th previous occurrence of <string>. +@item <count> ?<cr> +To the <count>th previous occurrence of <string> from previous @kbd{? or /}. +@item n +Repeat latest @kbd{/} @kbd{?} (next). +@item N +Repeat latest search in opposite direction. +@item C-c / +Without a prefix argument, this command toggles +case-sensitive/case-insensitive search modes and plain vanilla/regular +expression search. With the prefix argument 1, i.e., +@kbd{1 C-c /}, this toggles case-sensitivity; with the prefix argument 2, +toggles plain vanilla search and search using +regular expressions. @xref{Viper Specials}, for alternative ways to invoke +this function. +@cindex vanilla search +@cindex case-sensitive search +@cindex case-insensitive search +@item % +Find the next bracket/parenthesis/brace and go to its match. +By default, Viper ignores brackets/parentheses/braces that occur inside +parentheses. You can change this by setting +@code{vip-parse-sexp-ignore-comments} to nil in your @file{.viper} fipe. +This option can also be toggled interactively if you quickly hit @kbd{%} +three times. +@end table +@kindex @kbd{%} +@kindex @kbd{C-c /} +@kindex @kbd{N} +@kindex @kbd{n} +@kindex @kbd{?<cr>} +@kindex @kbd{/<cr>} +@kindex @kbd{?<string>} +@kindex @kbd{/<string>} +@kindex @kbd{''} +@kindex @kbd{``} +@kindex @kbd{]<a-z>} +@kindex @kbd{[<a-z>} +@kindex @kbd{'<a-z>} +@kindex @kbd{`<a-z>} +@kindex @kbd{m<a-z>} +@kindex @kbd{[]} +@kindex @kbd{[[} +@kindex @kbd{]]} +@kindex @kbd{@{} +@kindex @kbd{@}} +@kindex @kbd{(} +@kindex @kbd{)} +@kindex @kbd{M} +@kindex @kbd{L} +@kindex @kbd{H} +@kindex @kbd{G} +@kindex @kbd{E} +@kindex @kbd{e} +@kindex @kbd{B} +@kindex @kbd{b} +@kindex @kbd{W} +@kindex @kbd{w} +@kindex @kbd{,} +@kindex @kbd{;} +@kindex @kbd{T<char>} +@kindex @kbd{F<char>} +@kindex @kbd{t<char>} +@kindex @kbd{f<char>} +@kindex @kbd{|} +@kindex @kbd{0} +@kindex @kbd{<cr>} +@kindex @kbd{+} +@kindex @kbd{-} +@kindex @kbd{^} +@kindex @kbd{$} +@kindex @kbd{C-p} +@kindex @kbd{<lf>} +@kindex @kbd{<sp>} +@kindex @kbd{C-n} +@kindex @kbd{C-h} +@kindex @kbd{h} +@kindex @kbd{j} +@kindex @kbd{k} +@kindex @kbd{l} +@vindex @code{vip-parse-sexp-ignore-comments} + +@node Marking,Appending Text,Move Commands,Text Handling +@subsection Marking + +Emacs mark is referred to in the region specifiers @kbd{r} and @kbd{R}. +@xref{Emacs Preliminaries} and @pxref{Basics} for explanation. Also +see @ref{Mark,,Mark,emacs,The GNU Emacs manual}, for an explanation of +the Emacs mark ring. + +@cindex marking + +@table @kbd +@item m<a-z> +Mark the current file and position with the specified letter. +@item m . +Set the Emacs mark (@xref{Emacs Preliminaries}) at point. +@item m < +Set the Emacs mark at beginning of buffer. +@item m > +Set the Emacs mark at end of buffer. +@item m , +Jump to the Emacs mark. +@item :mark <char> + Mark position with text marker named <char>. This is an Ex command. +@item :k <char> + Same as @kbd{:mark}. +@item `` +Exchange point and mark. +@item '' +Exchange point and mark and go to the first CHAR on line. +@item '<a-z> +Go to specified Viper mark. +@item +Go to specified Viper mark and go to the first CHAR on line. +@end table +@kindex @kbd{m<a-z>} +@kindex @kbd{m.} +@kindex @kbd{m>} +@kindex @kbd{m<} +@kindex @kbd{m,} +@findex @kbd{:mark} +@findex @kbd{:k} +@kindex @kbd{''} +@kindex @kbd{``} +@kindex @kbd{`<a-z>} +@kindex @kbd{'<a-z>} + +@node Appending Text, Editing in Insert State, Marking,Text Handling +@subsection Appending Text + +@xref{Options} to see how to change tab and shiftwidth size. See the GNU +Emacs manual, or try @kbd{C-ha tabs} (If you have turned Emacs help on). +Check out the variable @code{indent-tabs-mode} to put in just spaces. +Also see options for word-wrap. + +@cindex inserting +@cindex appending +@cindex paste +@cindex put + +@table @kbd +@item <count> a +<count> times after the cursor. +@item <count> A +<count> times at the end of line. +@item <count> i +<count> times before the cursor (insert). +@item <count> I +<count> times before the first CHAR of the line +@item <count> o +On a new line below the current (open). +The count is only useful on a slow terminal. +@item <count> O +On a new line above the current. +The count is only useful on a slow terminal. +@item <count> ><move> +Shift the lines described by <count><move> one +shiftwidth to the right (layout!). +@item <count> >> +Shift <count> lines one shiftwidth to the right. +@item <count> ["<a-z1-9>]p +Put the contents of the (default undo) buffer +<count> times after the cursor. The register will +be automatically downcased. +@item <count> ["<a-z1-9>]P +Put the contents of the (default undo) buffer +<count> times before the cursor. The register will +@item [<a-z> +Show contents of textmarker. +@item ]<a-z> +Show contents of register. +@item <count> . +Repeat previous command <count> times. For destructive +commands as well as undo. +@item f1 1 and f1 2 +While @kbd{.} repeats the last destructive command, +these two macros repeat the second-last and the third-last destructive +commands. @xref{Vi Macros}, for more information on Vi macros. +@item C-c M-p and C-c M-n +In Vi state, +these commands help peruse the history of Vi's destructive commands. +Successive typing of @kbd{C-c M-p} causes Viper to search the history in +the direction +of older commands, while hitting @kbd{C-c M-n} does so in reverse +order. Each command in the history is displayed in the Minibuffer. The +displayed command can +then be executed by typing `@kbd{.}'. + +Since typing the above sequences of keys may be tedious, the +functions doing the perusing can be bound to unused keyboard keys in the +@file{~/.viper} file. @xref{Viper Specials}, for details. +@end table +@kindex @kbd{C-c M-p} +@kindex @kbd{C-c M-n} +@kindex @kbd{.} +@kindex @kbd{]<a-z>} +@kindex @kbd{[<a-z>} +@kindex @kbd{P} +@kindex @kbd{p} +@kindex @kbd{"<a-z1-9>p} +@kindex @kbd{"<a-z1-9>P} +@kindex @kbd{>>} +@kindex @kbd{><move>} +@kindex @kbd{O} +@kindex @kbd{o} +@kindex @kbd{i} +@kindex @kbd{A} +@kindex @kbd{a} + +@node Editing in Insert State, Deleting Text, Appending Text,Text Handling +@subsection Editing in Insert State + +Minibuffer can be edited similarly to Insert state, and you can switch +between Insert/Replace/Vi states at will. +Some users prefer plain Emacs feel in the Minibuffer. To this end, set +@var{vip-vi-style-in-minibuffer} to @code{nil}. + +@cindex Insert state + +@table @kbd +@item C-v +Deprive the next char of its special meaning (quoting). +@item C-h +One char back. +@item C-w +One word back. +@item C-u +Back to the begin of the change on the +current line. + +@end table +@kindex @kbd{C-u} +@kindex @kbd{C-w} +@kindex @kbd{C-v} + +@node Deleting Text, Changing Text, Editing in Insert State, Text Handling +@subsection Deleting Text + + +There is one difference in text deletion that you should be +aware of. This difference comes from Emacs and was adopted in Viper +because we find it very useful. In Vi, if you delete a line, say, and then +another line, these two deletions are separated and are put back +separately if you use the @samp{p} command. In Emacs (and Viper), successive +series of deletions that are @emph{not interrupted} by other commands are +lumped together, so the deleted text gets accumulated and can be put back +as one chunk. If you want to break a sequence of deletions so that the +newly deleted text could be put back separately from the previously deleted +text, you should perform a non-deleting action, e.g., move the cursor one +character in any direction. + +@cindex shifting text + +@table @kbd +@item <count> x +Delete <count> chars under and after the cursor. +@item <count> X +Delete <count> chars before the cursor. +@item <count> d<move> +Delete from point to endpoint of <count><move>. +@item <count> dd +Delete <count> lines. +@item D +The rest of the line. +@item <count> <<move> +Shift the lines described by <count><move> one +shiftwidth to the left (layout!). +@item <count> << +Shift <count> lines one shiftwidth to the left. +@end table +@kindex @kbd{<<} +@kindex @kbd{<<move>} +@kindex @kbd{D} +@kindex @kbd{dd} +@kindex @kbd{d<move>} +@kindex @kbd{X} +@kindex @kbd{x} + +@node Changing Text, Search and Replace, Deleting Text,Text Handling +@subsection Changing Text + +@cindex joining lines +@cindex changing case +@cindex quoting regions +@cindex substitution + +@table @kbd +@item <count> r<char> +Replace <count> chars by <char> - no <esc>. +@item <count> R +Overwrite the rest of the line, +appending change @var{count - 1} times. +@item <count> s +Substitute <count> chars. +@item <count> S +Change <count> lines. +@item <count> c<move> +Change from begin to endpoint of <count><move>. +@item <count> cc +Change <count> lines. +@item <count> C +The rest of the line and <count> - 1 next lines. +@item <count> =<move> +Reindent the region described by move. +@item <count> ~ +Switch lower and upper cases. +@item <count> J +Join <count> lines (default 2). +@item :[x,y]s/<p>/<r>/<f> +Substitute (on lines x through y) the pattern +<p> (default the last pattern) with <r>. Useful +flags <f> are @samp{g} for @samp{global} (i.e. change every +non-overlapping occurrence of <p>) and @samp{c} for +@samp{confirm} (type @samp{y} to confirm a particular +substitution, else @samp{n} ). Instead of @kbd{/} any +punctuation CHAR unequal to <space> <tab> and <lf> can be used as +delimiter. +@item :[x,y]copy [z] + Copy text between @kbd{x} and @kbd{y} to the position after @kbd{z}. +@item :[x,y]t [z] + Same as @kbd{:copy}. +@item :[x,y]move [z] + Move text between @kbd{x} and @kbd{y} to the position after @kbd{z}. +@item & +Repeat latest Ex substitute command, e.g. +@kbd{:s/wrong/good}. +@item C-c / +Toggle case-sensitive search. With prefix argument, toggle vanilla/regular +expression search. +@item #c<move> +Change upper-case characters in the region to lower-case. +@item #C<move> +Change lower-case characters in the region to upper-case. +@item #q<move> +Insert specified string at the beginning of each line in the region +@item C-c M-p and C-c M-n +In Insert and Replace states, these keys are bound to commands that peruse +the history of the text +previously inserted in other insert or replace commands. By repeatedly typing +@kbd{C-c M-p} or @kbd{C-c M-n}, you will cause Viper to +insert these previously used strings one by one. +When a new string is inserted, the previous one is deleted. + +In Vi state, these keys are bound to functions that peruse the history of +destructive Vi commands. +@xref{Viper Specials}, for details. +@end table +@kindex @kbd{C-c M-p} +@kindex @kbd{C-c M-n} +@kindex @kbd{#q<move> } +@kindex @kbd{#C<move>} +@kindex @kbd{#c<move>} +@kindex @kbd{&} +@findex @kbd{:substitute/<p>/<r>/<f>} +@findex @kbd{:s/<p>/<r>/<f>} +@findex @kbd{:copy [z]} +@findex @kbd{:t [z]} +@findex @kbd{:move [z]} +@kindex @kbd{J} +@kindex @kbd{~} +@kindex @kbd{=<move>} +@kindex @kbd{C} +@kindex @kbd{cc} +@kindex @kbd{c<move>} +@kindex @kbd{S} +@kindex @kbd{s} +@kindex @kbd{R} +@kindex @kbd{r<char>} + +@node Search and Replace, Yanking, Changing Text,Text Handling +@subsection Search and Replace + +@xref{Groundwork}, for Ex address syntax. @xref{Options} to see how to +get literal (non-regular-expression) search and how to stop search from +wrapping around. + +@table @kbd +@item <count> /<string> +To the <count>th occurrence of <string>. +@item <count> ?<string> +To the <count>th previous occurrence of <string>. +@item <count> g<move> +Search for the text described by move. (off by default) +@item n +Repeat latest @kbd{/} @kbd{?} (next). +@item N +Idem in opposite direction. +@item % +Find the next bracket and go to its match +@item :[x,y]g/<string>/<cmd> +@cindex text processing +Search globally [from line x to y] for <string> +and execute the Ex <cmd> on each occurrence. +@item :[x,y]v/<string>/<cmd> +Execute <cmd> on the lines that don't match. +@item #g<move> +Execute the last keyboard macro for each line in the region. +@xref{Macros and Registers}, for more info. +@item Q +Query Replace. +@item :ta <name> +Search in the tags file where <name> is defined (file, line), and go to it. +@item :[x,y]s/<p>/<r>/<f> +Substitute (on lines x through y) the pattern <p> (default the last +pattern) with <r>. Useful +flags <f> are @samp{g} for @samp{global} (i.e. change every +non-overlapping occurrence of <p>) and @samp{c} for +@samp{confirm} (type @samp{y} to confirm a particular +substitution, else @samp{n}). Instead of @kbd{/} any +punctuation CHAR unequal to <space> <tab> and <lf> can be used as delimiter. +@item & + Repeat latest Ex substitute command, e.g. @kbd{:s/wrong/good}. +@end table +@kindex @kbd{&} +@findex @kbd{:substitute/<p>/<r>/<f>} +@kindex @kbd{Q} +@kindex @kbd{#g<move>} +@findex @kbd{:v/<string>/<cmd>} +@findex @kbd{:g/<string>/<cmd>} +@findex @kbd{:global/<string>/<cmd>} +@findex @kbd{:tag <name>} +@kindex @kbd{%} +@kindex @kbd{N} +@kindex @kbd{n} +@kindex @kbd{g<move>} +@kindex @kbd{?<string>} +@kindex @kbd{/<string>} + +@node Yanking,Undoing,Search and Replace,Text Handling +@subsection Yanking + +@cindex cut and paste +@cindex paste + +@table @kbd +@item <count> y<move> +Yank from begin to endpoint of <count><move>. +@item <count> "<a-z>y<move> +Yank from begin to endpoint of <count><move> to register. +@item <count> "<A-Z>y<move> +Yank from begin to endpoint of <count><move> and append +to register. +@item <count> yy +<count> lines. +@item <count> Y +Idem (should be equivalent to @kbd{y$} though). +@item m<a-z> +Mark the cursor position with a letter. +@item [<a-z> +Show contents of textmarker. +@item ]<a-z> +Show contents of register. +@item <count> ["<a-z1-9>]p +Put the contents of the (default undo) buffer +<count> times after the cursor. The register will +be automatically downcased. +@item <count> ["<a-z1-9>]P +Put the contents of the (default undo) buffer +<count> times before the cursor. The register will +@end table +@kindex @kbd{P} +@kindex @kbd{p} +@kindex @kbd{"<a-z1-9>p} +@kindex @kbd{"<a-z1-9>P} +@kindex @kbd{]<a-z>} +@kindex @kbd{[<a-z>} +@kindex @kbd{m<a-z>} +@kindex @kbd{Y} +@kindex @kbd{yy} +@kindex @kbd{"<A-Z>y<move>} +@kindex @kbd{"<a-z>y<move>} +@kindex @kbd{y<move>} +@kindex @kbd{yank} +@findex @kbd{:yank} + +@node Undoing,, Yanking,Text Handling +@subsection Undoing + +@cindex undo +@cindex backup files + +@table @kbd +@item u U +Undo the latest change. +@item . +Repeat undo. +@item :q! +Quit Vi without writing. +@item :e! +Re-edit a messed-up file. +@item :rec +Recover file from autosave. Viper also creates backup files +that have a @samp{~} appended to them. +@end table +@findex @kbd{:rec} +@findex @kbd{:e!} +@findex @kbd{:q!} +@kindex @kbd{.} +@kindex @kbd{U} +@kindex @kbd{u} + +@node Display, File and Buffer Handling, Text Handling, Commands +@section Display + +@cindex scrolling + +@table @kbd +@item C-g +At user level 1, +give file name, status, current line number +and relative position. @* +At user levels 2 and higher, abort the current command. +@item C-c g +Give file name, status, current line number and relative position -- all +user levels. +@item C-l +Refresh the screen. +@item <count> C-e +Expose <count> more lines at bottom, cursor stays put (if possible). +@item <count> C-y +Expose <count> more lines at top, cursor stays put (if possible). +@item <count> C-d +Scroll <count> lines downward (default the number of the previous scroll; +initialization: half a page). +@item <count> C-u +Scroll <count> lines upward (default the number of the previous scroll; +initialization: half a page). +@item <count> C-f +<count> pages forward. +@item <count> C-b +<count> pages backward (in older versions @kbd{C-b} only works without count). +@item <count> z<cr> +@item zH +Put line <count> at the top of the window (default the current line). +@item <count> z- +@item zL +Put line <count> at the bottom of the window +(default the current line). +@item <count> z. +@item zM +Put line <count> in the center of the window +(default the current line). +@end table +@kindex @kbd{zM} +@kindex @kbd{zL} +@kindex @kbd{zH} +@kindex @kbd{z<cr>} +@kindex @kbd{z.} +@kindex @kbd{z-} +@kindex @kbd{z<cr>} +@kindex @kbd{C-b} +@kindex @kbd{C-f} +@kindex @kbd{C-u} +@kindex @kbd{C-d} +@kindex @kbd{C-y} +@kindex @kbd{C-e} +@kindex @kbd{C-l} +@kindex @kbd{C-g} + + +@node File and Buffer Handling, Mapping, Display,Commands +@section File and Buffer Handling + +@cindex multiple files + +In all file handling commands, space should be typed before entering the file +name. If you need to type a modifier, such as @kbd{>>} or @kbd{!}, don't +put any space between the command and the modifier. + +@table @kbd +@item :q +Quit buffer except if modified. +@item :q! +Quit buffer without checking. In Viper, these two commands +are identical. Confirmation is required if exiting modified buffers that +visit files. +@item :susp +@item :stop +Suspend Viper +@item :[x,y] w +Write the file. Viper nakes sure that a final newline is always added to +any file where this newline is missing. This is done by setting Emacs +variable @code{require-final-newline} to @code{t}. If you don't like this +feature, use @code{setq-default} to set @code{require-final-newline} to +@code{nil}. This must be done either in @file{.viper} file or in +@code{.emacs} after Viper is loaded. +@item :[x,y] w <name> +Write to the file <name>. +@item :[x,y] w>> <name> +Append the buffer to the file <name>. There should be no space between +@kbd{w} and @kbd{>>}. Type space after the @kbd{>>} and see what happens. +@item :w! <name> +Overwrite the file <name>. In Viper, @kbd{:w} and @kbd{:w!} are identical. +Confirmation is required for writing to an existing file (if this is not +the file the buffer is visiting) or to a read-only file. +@item :x,y w <name> +Write lines x through y to the file <name>. +@item :wq +Write the file and kill buffer. +@item :r <file> [<file> ...] +Read file into a buffer, inserting its contents after the current line. +@item :xit +Same as @kbd{:wq}. +@item :W +Save unsaved buffers, asking for confirmation. +@item :WW +Like @kbd{W}, but without asking for confirmation. +@item ZZ +Save current buffer and kill it. If user level is 1, then save all files +and kill Emacs. Killing Emacs is the wrong way to use it, so you should +switch to higher user levels as soon as possible. +@item :x [<file>] +Save and kill buffer. +@item :x! [<file>] +@kbd{:w![<file>]} and @kbd{:q}. +@item :pre +Preserve the file -- autosave buffers. +@item :rec +Recover file from autosave. +@item :f +Print file name and lines. +@item :cd [<dir>] +Set the working directory to <dir> (default home directory). +@item :pwd +Print present working directory. +@item :e [+<cmd>] <files> +Edit files. If no filename is given, edit the file visited by the current +buffer. If buffer was modified or the file changed on disk, ask for +confirmation. Unlike Vi, Viper allows @kbd{:e} to take multiple arguments. +The first file is edited the same way as in Vi. The rest are visited +in the usual Emacs way. +@item :e! [+<cmd>] <files> +Re-edit file. If no filename, reedit current file. +In Viper, unlike Vi, @kbd{e!} is identical to @kbd{:e}. In both cases, the +user is asked to confirm if there is a danger of discarding changes to a +buffer. +@item :q! +Quit Vi without writing. +@item C-^ +Edit the alternate (normally the previous) file. +@item :rew +Obsolete +@item :args +List files not shown anywhere with counts for next +@item :n [count] [+<cmd>] [<files>] +Edit <count> file, or edit files. The count comes from :args. +@item :N [count] [+<cmd>] [<files>] +Like @kbd{:n}, but the meaning of the variable +@var{ex-cycle-other-window} is reversed. +@item :b +Switch to another buffer. If @var{ex-cycle-other-window} is @code{t}, +switch in another window. Buffer completion is supported. +@item :B +Like @kbd{:b}, but the meaning of @var{ex-cycle-other-window} is reversed. +@item :<address>r <name> +Read the file <name> into the buffer after the line <address>. +@item v, V, C-v +Edit a file in current or another window, or in another frame. File name +is typed in Minibuffer. File completion and history are supported. +@end table +@kindex @kbd{v} +@kindex @kbd{V} +@findex @kbd{:args} +@findex @kbd{:rew} +@kindex @kbd{C-^} +@findex @kbd{:e! [<files>]} +@findex @kbd{:e [<files>]} +@findex @kbd{:edit [<files>]} +@findex @kbd{:edit! [<files>]} +@findex @kbd{:q!} +@findex @kbd{:q} +@findex @kbd{:quit} +@findex @kbd{:quit!} +@findex @kbd{:f} +@findex @kbd{:rec} +@findex @kbd{:r} +@findex @kbd{:read} +@findex @kbd{:pre} +@kindex @kbd{ZZ} +@findex @kbd{:wq} +@findex @kbd{:w <file>} +@findex @kbd{:w! <file>} +@findex @kbd{:w >> <file>} +@findex @kbd{:write <file>} +@findex @kbd{:write! <file>} +@findex @kbd{:write >> <file>} +@findex @kbd{:W} +@findex @kbd{:WW} +@findex @kbd{:Write} +@findex @kbd{:WWrite} +@findex @kbd{:WWrite} +@findex @kbd{:x} +@findex @kbd{:x!} +@findex @kbd{:susp} +@findex @kbd{:stop} +@findex @kbd{:n [<count> | <file>]} +@findex @kbd{:cd [<dir>]} +@findex @kbd{:pwd} + +@node Mapping, Shell Commands, File and Buffer Handling, Commands +@section Mapping + +@cindex keybindings +@cindex keymapping + +@table @kbd +@item :map <string> + Start defining a Vi-style keyboard macro. + For instance, typing + @kbd{:map www} followed by @kbd{:!wc %} and then typing @kbd{C-x )} + will cause @kbd{www} to run wc on + current file (Vi replaces @samp{%} with the current file name). +@item C-x ) + Finish defining a keyboard macro. + In Viper, this command completes the process of defining all keyboard +macros, whether they are Emacs-style or Vi-style. +This is a departure from Vi, needed to allow WYSIWYG mapping of +keyboard macros and to permit the use of function keys and arbitrary Emacs +functions in the macros. +@item :unmap <string> + Deprive <string> of its mappings in Vi state. +@item :map! <string> + Map a macro for Insert state. +@item :unmap! <string> + Deprive <string> of its mapping in Insert state (see @kbd{:unmap}). +@item @@<a-z> + In Vi state, + execute the contents of register as a command. +@item @@@@ + In Vi state, + repeat last register command. +@item @@# +In Vi state, + begin keyboard macro. End with @@<a-z>. This will + put the macro in the proper register. Register will + be automatically downcased. + @xref{Macros and Registers}, for more info. +@item @@!<a-z> + In Vi state, + yank anonymous macro to register +@item * + In Vi state, + execute anonymous macro (defined by C-x( and C-x )). +@item C-x e + Like @kbd{*}, but works in all Viper states. +@item #g<move> + Execute the last keyboard macro for each line in the region. + @xref{Macros and Registers}, for more info. +@item [<a-z> + Show contents of textmarker. +@item ]<a-z> + Show contents of register. +@end table +@kindex @kbd{]<a-z>} +@kindex @kbd{[<a-z>} +@kindex @kbd{#g<move>} +@kindex @kbd{*} +@kindex @kbd{@@!<a-z>} +@kindex @kbd{@@#} +@kindex @kbd{@@@@} +@kindex @kbd{@@<a-z>} +@findex @kbd{:unmap <char>} +@findex @kbd{:map <char> <seq>} +@findex @kbd{:unmap! <char>} +@findex @kbd{:map! <char> <seq>} + +@node Shell Commands, Options, Mapping, Commands +@section Shell Commands + +@cindex % (Current file) + +Note that % is used in Ex commands to mean current file. If you want a % +in your command, it must be escaped as @samp{\%}. +@cindex % (Ex address) +However if % is the +first character, it stands as the address for the whole file. +@cindex # (Previous file) +Similarly, @samp{#} expands to the previous file. The previous file is +the first file in @kbd{:args} listing. This defaults +to the previous file in the VI sense if you have one window.@refill + +@cindex shell commands + +@table @kbd +@item :sh +Execute a subshell in another window +@item :[x,y]!<cmd> +Execute a shell <cmd> [on lines x through y; +% is replace by current file, \% is changed to % +@item :[x,y]!! [<args>] +Repeat last shell command [and append <args>]. +@item :!<cmd> +Just execute command and display result in a buffer. +@item :!! <args> +Repeat last shell command and append <args> +@item <count> !<move><cmd> +The shell executes <cmd>, with standard +input the lines described by <count><move>, +next the standard output replaces those lines +(think of @samp{cb}, @samp{sort}, @samp{nroff}, etc.). +@item <count> !!<cmd> +Give <count> lines as standard input to the +shell <cmd>, next let the standard output +replace those lines. +@item :[x,y] w !<cmd> +Let lines x to y be standard input for <cmd> +(notice the <sp> between @kbd{w} and @kbd{!}). +@item :<address>r !<cmd> +Put the output of <cmd> after the line <address> (default current). +@item :<address>r <name> +Read the file <name> into the buffer after the line <address> (default +current). +@end table +@findex @kbd{:<address>r <name>} +@findex @kbd{:<address>r !<cmd>} +@findex @kbd{!<cmd>} +@findex @kbd{!!<cmd>} +@findex @kbd{!<move><cmd>} +@findex @kbd{:w !<cmd>} +@findex @kbd{:x,y w !<cmd>} +@findex @kbd{:!! <args>} +@findex @kbd{:!<cmd>} +@findex @kbd{:sh} + +@node Options,Emacs Related Commands,Shell Commands,Commands +@section Options + +@cindex Vi options + +@table @kbd +@item ai +@cindex autoindent +autoindent -- In append mode after a <cr> the +cursor will move directly below the first +CHAR on the previous line. +@item ic +@cindex case and searching +ignorecase -- No distinction between upper and lower cases when searching. +@item magic +@cindex literal searching +Regular expressions used in searches; nomagic means no regexps. +@item ro +@cindex readonly files +readonly -- The file is not to be changed. +If the user attempts to write to this file, confirmation will be requested. +@item sh=<string> +@cindex shell +shell -- The program to be used for shell escapes +(default @samp{$SHELL} (default @file{/bin/sh})). +@item sw=<count> +@cindex layout +@cindex shifting text +shiftwidth -- Gives the shiftwidth (default 8 positions). +@item sm +@cindex paren matching +@cindex matching parens +showmatch -- Whenever you append a @kbd{)}, Vi shows +its match if it's on the same page; also with +@kbd{@{} and @kbd{@}}. If there's no match, Vi will beep. +@item ts=<count> +@cindex changing tab width +@cindex tabbing +tabstop -- The length of a <ht>; warning: this is +only IN the editor, outside of it <ht>s have +their normal length (default 8 positions). +@item wm=<count> +@cindex auto fill +@cindex word wrap +wrapmargin -- In append mode Vi automatically +puts a <lf> whenever there is a <sp> or <ht> +within <wm> columns from the right margin. +@item ws +@cindex searching +wrapscan -- When searching, the end is +considered @samp{stuck} to the begin of the file. +@item :set <option> +Turn <option> on. +@item :set no<option> +Turn <option> off. +@item :set <option>=<value> +Set <option> to <value>. +@end table +@findex @kbd{:set <option>=<value>} +@findex @kbd{:set no<option>} +@findex @kbd{:set <option>} +@findex @kbd{:set ws} +@findex @kbd{:set wrapscan} +@findex @kbd{:set wm=<count>} +@findex @kbd{:set wrapmargin=<count>} +@findex @kbd{:set ts=<count>} +@findex @kbd{:set tabstop=<count>} +@findex @kbd{:set tab-stop-local=<count>} +@findex @kbd{:set sm} +@findex @kbd{:set showmatch} +@findex @kbd{:set sw=<count>} +@findex @kbd{:set shiftwidth=<count>} +@findex @kbd{:set sh=<string>} +@findex @kbd{:set shell=<string>} +@findex @kbd{:set ro} +@findex @kbd{:set readonly} +@findex @kbd{:set magic} +@findex @kbd{:set ic} +@findex @kbd{:set ignorecase} +@findex @kbd{:set ai} +@findex @kbd{:set autoindent} + +@node Emacs Related Commands,,Options,Commands +@section Emacs Related Commands + +@table @kbd +@item _ +Begin Meta command in Vi state. Most often used as _x (M-x). +@item C-z +Begin Meta command in Insert state. +@item C-z +Switch between Emacs and Vi states. +@item C-x0 +Close Window +@item C-x1 +Close Other Windows +@item C-x2 +Split Window +@item C-xo +Move among windows +@item C-xC-f +Emacs find-file, useful in Insert state +@item C-y +Put back the last killed text. Similar to Vi's @kbd{p}, but also works in +Insert and Replace state. This command doesn't work in Vi command state, +since this binding is taken for something else. +@item M-y +Undoes the last @kbd{C-y} and puts another kill from the kill ring. +Using this command, you can try may different kills until you find the one +you need. +@end table +@kindex @kbd{M-y} +@kindex @kbd{C-y} +@kindex @kbd{C-xC-f} +@kindex @kbd{C-xo} +@kindex @kbd{C-x2} +@kindex @kbd{C-x1} +@kindex @kbd{C-x0} +@kindex @kbd{C-z} +@kindex @kbd{C-z} +@kindex @kbd{_} + +@node Mouse-bound Commands,,,Commands +@section Mouse-bound Commands + +The following two mouse actions are normally bound to to special search and +insert commands in of Viper: + +@table @kbd +@item S-mouse-1 (Emacs) +@item meta button1up (XEmacs) +Holding Shift (or Meta, if XEmacs) and clicking mouse button 1 will +initiate search for +a region under the mouse pointer. +This command can take a prefix argument. Note: Viper sets this +binding only if this mouse action is not +already bound to something else. +@xref{Viper Specials}, for more information.@refill + +@item S-mouse-2 (Emacs) +@item meta button2up (XEmacs) +Holding Shift (or Meta, if XEmacs) and clicking button 2 of the mouse will +insert a region surrounding the mouse pointer. +This command can also take a prefix argument. +Note: Viper sets this binding only if this mouse action is not +already bound to something else. +@xref{Viper Specials}, for more details.@refill +@end table +@kindex @kbd{S-mouse-1} +@kindex @kbd{S-mouse-2} +@kindex @kbd{meta button1up} +@kindex @kbd{meta button2up} @node Acknowledgments,,,Top @comment node-name, next, previous, up