viper.texi(,3) 
viper.texi(,4) @comment Using viper.info instead of viper in setfilename breaks DOS.
viper.texi(,5) @comment @setfilename viper
viper.texi(,6) @comment @setfilename viper.info
viper.texi(,7) @setfilename viper
viper.texi(,8) 
viper.texi(,9) @dircategory Editors
viper.texi(,15) 
viper.texi(,19) 
viper.texi(,20) @titlepage
viper.texi(,21) @title Viper Is a Package for Emacs Rebels
viper.texi(,22) @subtitle a Vi emulator for Emacs
viper.texi(,23) @subtitle January 2002, Viper Version 3.11.2
viper.texi(,24) 
viper.texi(,25) @author Michael Kifer (Viper)
viper.texi(,26) @author Aamod Sane (VIP 4.4)
viper.texi(,27) @author Masahiko Sato (VIP 3.5)
viper.texi(,28) 
viper.texi(,29) @page
viper.texi(,30) @vskip 0pt plus 1fill
viper.texi(,31) @end titlepage
viper.texi(,32) 
viper.texi(,33) @unnumbered Distribution
viper.texi(,34) 
viper.texi(,35) @noindent
viper.texi(,36) Copyright @copyright{} 1995, 1996, 1997, 2001, 2002 Free Software Foundation, Inc.
viper.texi(,37) 
viper.texi(,38) Permission is granted to copy, distribute and/or modify this document
viper.texi(,39) under the terms of the GNU Free Documentation License, Version 1.1 or
viper.texi(,40) any later version published by the Free Software Foundation; with no
viper.texi(,41) Invariant Sections, with the Front-Cover texts being ``A GNU
viper.texi(,42) Manual'', and with the Back-Cover Texts as in (a) below.  A copy of the
viper.texi(,43) license is included in the section entitled ``GNU Free Documentation
viper.texi(,44) License'' in the Emacs manual.
viper.texi(,45) 
viper.texi(,46) (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
viper.texi(,47) this GNU Manual, like GNU software.  Copies published by the Free
viper.texi(,48) Software Foundation raise funds for GNU development.''
viper.texi(,49) 
viper.texi(,50) This document is part of a collection distributed under the GNU Free
viper.texi(,51) Documentation License.  If you want to distribute this document
viper.texi(,52) separately from the collection, you can do so by adding a copy of the
viper.texi(,53) license to the document, as described in section 6 of the license.
viper.texi(,54) 
viper.texi(,56) @node Top, Overview,, (DIR)
viper.texi(,57) 
viper.texi(,58) @unnumbered Viper
viper.texi(,59) 
viper.texi(,60) We believe that one or more of the following statements are adequate
viper.texi(,61) descriptions of Viper:
viper.texi(,62) 
viper.texi(,63) @example
viper.texi(,64) Viper Is a Package for Emacs Rebels;
viper.texi(,65) it is a VI Plan for Emacs Rescue
viper.texi(,66) and/or a venomous VI PERil.
viper.texi(,67) @end example
viper.texi(,68) 
viper.texi(,69) Technically speaking, Viper is a Vi emulation package for Emacs.  It
viper.texi(,70) implements all Vi and Ex commands, occasionally improving on them and
viper.texi(,71) adding many new features.  It gives the user the best of both worlds: Vi
viper.texi(,72) keystrokes for editing combined with the power of the Emacs environment.
viper.texi(,73) 
viper.texi(,74) Viper emulates Vi at several levels, from the one that closely follows Vi
viper.texi(,75) conventions to the one that departs from many of them.  It has many
viper.texi(,76) customizable options, which can be used to tailor Viper to the work habits
viper.texi(,77) of various users.
viper.texi(,78) This manual describes Viper, concentrating on the differences from Vi and
viper.texi(,79) new features of Viper.
viper.texi(,80) 
viper.texi(,81) Viper, formerly known as VIP-19, was written by Michael Kifer.  It is based
viper.texi(,82) on VIP version 3.5 by Masahiko Sato and VIP version 4.4 by Aamod Sane.
viper.texi(,83) About 15% of the code still comes from those older packages.
viper.texi(,84) 
viper.texi(,85) Viper is intended to be usable without reading this manual --- the defaults
viper.texi(,86) are set to make Viper as close to Vi as possible.  At startup, Viper will
viper.texi(,87) try to set the most appropriate default environment for you, based on
viper.texi(,88) your familiarity with Emacs.  It will also tell you the basic GNU Emacs window
viper.texi(,89) management commands to help you start immediately.
viper.texi(,90) 
viper.texi(,91) Although this manual explains how to customize Viper, some basic
viper.texi(,92) familiarity with Emacs Lisp is a plus.
viper.texi(,93) 
viper.texi(,94) It is recommended that you read the Overview node.  The other nodes may
viper.texi(,95) be visited as needed.
viper.texi(,96) 
viper.texi(,97) Comments and bug reports are welcome.
viper.texi(,98) @code{kifer@@cs.stonybrook.edu} is the current address for Viper bug reports.
viper.texi(,99) Please use the Ex command @kbd{:submitReport} for this purpose.@refill
viper.texi(,100) 
viper.texi(,102) 
viper.texi(,103) @menu
viper.texi(,104) * Overview::                    Read for a smoother start
viper.texi(,105) * Improvements over Vi::        New features, Improvements
viper.texi(,106) * Customization::               How to customize Viper
viper.texi(,107) * Commands::                    Vi and Ex Commands
viper.texi(,108) 
viper.texi(,109) * Key Index::                   Index of Vi and Ex Commands
viper.texi(,110) * Function Index::              Index of Viper Functions
viper.texi(,111) * Variable Index::              Index of Viper Variables
viper.texi(,112) * Package Index::               Index of Packages Mentioned in this Document
viper.texi(,113) * Concept Index::               Vi, Ex and Emacs concepts
viper.texi(,114) 
viper.texi(,115) * Acknowledgments::
viper.texi(,116) @end menu
viper.texi(,161) 
viper.texi(,162) @node Overview,Improvements over Vi,Top,Top
viper.texi(,163) @chapter Overview of Viper
viper.texi(,164) 
viper.texi(,165) Viper is a Vi emulation on top of Emacs.  At the same time, Viper provides a
viper.texi(,166) virtually unrestricted access to Emacs facilities.  Perfect compatibility
viper.texi(,167) with Vi is possible but not desirable.  This chapter tells you about the
viper.texi(,168) Emacs ideas that you should know about, how to use Viper within Emacs and
viper.texi(,169) some incompatibilities.
viper.texi(,170) 
viper.texi(,171) This manual is written with the assumption that you are an experienced Vi
viper.texi(,172) user who wants to switch to Emacs while retaining the ability to edit files
viper.texi(,173) Vi style. Incredible as it might seem, there are experienced Emacs users
viper.texi(,174) who use Viper as a backdoor into the superior (as every Vi user already knows)
viper.texi(,175) world of Vi! These users are well familiar with Emacs bindings and prefer them
viper.texi(,176) in some cases, especially in the Vi Insert state. John Hawkins
viper.texi(,177) <jshawkin@@eecs.umich.edu> has provided a set of customizations, which
viper.texi(,178) enables additional Emacs bindings under Viper.  These customizations can be
viper.texi(,179) included in your @file{~/.viper} file and are found at the following URL:
viper.texi(,180) @file{http://www.eecs.umich.edu/~jshawkin/viper-sample}.
viper.texi(,181) 
viper.texi(,182) @menu
viper.texi(,183) * Emacs Preliminaries::         Basic concepts in Emacs.
viper.texi(,184) * Loading Viper::               Loading and Preliminary Configuration.
viper.texi(,185) * States in Viper::             Viper has four states orthogonal to Emacs
viper.texi(,186)                                 modes.
viper.texi(,187) * The Minibuffer::              Command line in Emacs.
viper.texi(,188) * Multiple Files in Viper::     True multiple file handling.
viper.texi(,189) * Unimplemented Features::      That are unlikely to be implemented.
viper.texi(,190) @end menu
viper.texi(,191) 
viper.texi(,192) @node Emacs Preliminaries, Loading Viper, Overview, Overview
viper.texi(,193) @section Emacs Preliminaries
viper.texi(,194) 
viper.texi(,195) @cindex buffer
viper.texi(,196) @cindex point
viper.texi(,197) @cindex mark
viper.texi(,198) @cindex text
viper.texi(,199) @cindex looking at
viper.texi(,200) @cindex end (of buffer)
viper.texi(,201) @cindex end (of line)
viper.texi(,202) @cindex region
viper.texi(,203) 
viper.texi(,204) Emacs can edit several files at once.  A file in Emacs is placed in a
viper.texi(,205) @dfn{buffer} that usually has the same name as the file.  Buffers are also used
viper.texi(,206) for other purposes, such as shell interfaces, directory editing, etc.
viper.texi(,207) @xref{Dired,,Directory Editor,emacs,The
viper.texi(,208) Gnu Emacs Manual}, for an example.@refill
viper.texi(,209) 
viper.texi(,210) A buffer has a distinguished position called the @dfn{point}.
viper.texi(,211) A @dfn{point} is always between 2 characters, and is @dfn{looking at}
viper.texi(,212) the right hand character.  The cursor is positioned on the right hand
viper.texi(,213) character.  Thus, when the @dfn{point} is looking at the end-of-line,
viper.texi(,214) the cursor is on the end-of-line character, i.e.@: beyond the last
viper.texi(,215) character on the line.  This is the default Emacs behavior.@refill
viper.texi(,216) 
viper.texi(,217) The default settings of Viper try to mimic the behavior of Vi, preventing
viper.texi(,218) the cursor from going beyond the last character on the line.  By using
viper.texi(,219) Emacs commands directly (such as those bound to arrow keys), it is possible
viper.texi(,220) to get the cursor beyond the end-of-line.  However, this won't (or
viper.texi(,221) shouldn't) happen if you restrict yourself to standard Vi keys, unless you
viper.texi(,222) modify the default editing style.  @xref{Customization}.@refill
viper.texi(,223) 
viper.texi(,224) In addition to the @dfn{point}, there is another distinguished buffer
viper.texi(,225) position called the @dfn{mark}.  @xref{Mark,,Mark,emacs,The GNU Emacs
viper.texi(,226) manual}, for more info on the mark.  The text between the @dfn{point} and
viper.texi(,227) the @dfn{mark} is called the @dfn{region} of the buffer.  For the Viper
viper.texi(,228) user, this simply means that in addition to the Vi textmarkers a--z, there
viper.texi(,229) is another marker called @dfn{mark}.  This is similar to the unnamed Vi
viper.texi(,230) marker used by the jump commands @kbd{``} and @kbd{''}, which move the
viper.texi(,231) cursor to the position of the last absolute jump.  Viper provides access to
viper.texi(,232) the region in most text manipulation commands as @kbd{r} and @kbd{R} suffix
viper.texi(,233) to commands that operate on text regions, e.g., @kbd{dr} to delete region,
viper.texi(,234) etc.
viper.texi(,235) 
viper.texi(,236) Furthermore, Viper lets Ex-style commands to work on the current region.
viper.texi(,237) This is done by typing a digit argument before @kbd{:}.  For instance,
viper.texi(,238) typing @kbd{1:} will propmt you with something like @emph{:123,135},
viper.texi(,239) assuming that the current region starts at line 123 and ends at line
viper.texi(,240) 135.  There is no need to type the line numbers, since Viper inserts them
viper.texi(,241) automatically in front of the Ex command.
viper.texi(,242) 
viper.texi(,243) @xref{Basics}, for more info.@refill
viper.texi(,244) 
viper.texi(,245) @cindex window
viper.texi(,246) @cindex mode line
viper.texi(,247) @cindex buffer information
viper.texi(,248) @cindex Minibuffer
viper.texi(,249) @cindex command line
viper.texi(,250) @cindex buffer (modified)
viper.texi(,251) 
viper.texi(,252) Emacs divides the screen into tiled @dfn{windows}.  You can see the
viper.texi(,253) contents of a buffer through the window associated with the buffer.  The
viper.texi(,254) cursor of the screen is positioned on the character after @dfn{point}.
viper.texi(,255) Every window has a @dfn{mode line} that displays information about the buffer.
viper.texi(,256) You can change the format of the mode
viper.texi(,257) line, but normally if you see @samp{**} at the beginning of a mode line it
viper.texi(,258) means that the buffer is @dfn{modified}.  If you write out the contents of
viper.texi(,259) a buffer to a file, then the buffer will become not modified.  Also if
viper.texi(,260) you see @samp{%%} at the beginning of the mode line, it means that the file
viper.texi(,261) associated with the buffer is write protected.  The mode line will also
viper.texi(,262) show the buffer name and current major and minor modes (see below).
viper.texi(,263) A special buffer called @dfn{Minibuffer} is displayed as the last line
viper.texi(,264) in a Minibuffer window.  The Minibuffer window is used for command input
viper.texi(,265) output.  Viper uses Minibuffer window for @kbd{/} and @kbd{:}
viper.texi(,266) commands.@refill
viper.texi(,267) 
viper.texi(,268) @cindex mode
viper.texi(,269) @cindex keymap
viper.texi(,270) @cindex local keymap
viper.texi(,271) @cindex global keymap
viper.texi(,272) @cindex major mode
viper.texi(,273) @cindex minor mode
viper.texi(,274) 
viper.texi(,275) An Emacs buffer can have a @dfn{major mode} that customizes Emacs for
viper.texi(,276) editing text of a particular sort by changing the functionality of the keys.
viper.texi(,277) Keys are defined using a @dfn{keymap} that records the bindings between
viper.texi(,278) keystrokes and
viper.texi(,279) functions.  The @dfn{global keymap} is common to all the
viper.texi(,280) buffers.  Additionally, each buffer has its @dfn{local keymap} that determines the
viper.texi(,281) @dfn{mode} of the buffer.  If a function is bound to some key in the local
viper.texi(,282) keymap then that function will be executed when you type the key.
viper.texi(,283) If no function is bound to a key in the
viper.texi(,284) local map, however, the function bound to the key in the global map
viper.texi(,285) will be executed.  @xref{Major Modes,Major Modes,Major Modes,emacs,The
viper.texi(,286) GNU Emacs Manual}, for more information.@refill
viper.texi(,287) 
viper.texi(,288) A buffer can also have a @dfn{minor mode}.  Minor modes are options that
viper.texi(,289) you can use or not.  A buffer in @code{text-mode} can have
viper.texi(,290) @code{auto-fill-mode} as minor mode, which can be turned off or on at
viper.texi(,291) any time.  In Emacs, a minor mode may have it own keymap,
viper.texi(,292) which overrides the local keymap when the minor mode is turned on.  For
viper.texi(,293) more information, @pxref{Minor Modes,Minor Modes,Minor Modes,emacs,The
viper.texi(,294) GNU Emacs Manual} @refill
viper.texi(,295) 
viper.texi(,296) @cindex Viper as minor mode
viper.texi(,297) @cindex Control keys
viper.texi(,298) @cindex Meta key
viper.texi(,299) 
viper.texi(,300) Viper is implemented as a collection of minor modes.  Different minor modes
viper.texi(,301) are involved when Viper emulates Vi command mode, Vi insert mode, etc.
viper.texi(,302) You can also turn Viper on and off at any time while in Vi command mode.
viper.texi(,303) @xref{States in Viper}, for
viper.texi(,304) more information.@refill
viper.texi(,305) 
viper.texi(,306) Emacs uses Control and Meta modifiers.  These are denoted as C and M,
viper.texi(,307) e.g.@: @kbd{^Z} as @kbd{C-z} and @kbd{Meta-x} as @kbd{M-x}.  The Meta key is
viper.texi(,308) usually located on each side of the Space bar; it is used in a manner
viper.texi(,309) similar to the Control key, e.g., @kbd{M-x} means typing @kbd{x} while
viper.texi(,310) holding the Meta key down.  For keyboards that do not have a Meta key,
viper.texi(,311) @key{ESC} is used as Meta.  Thus @kbd{M-x} is typed as @kbd{@key{ESC}
viper.texi(,312) x}.  Viper uses @key{ESC} to switch from Insert state to Vi state.  Therefore
viper.texi(,313) Viper defines @kbd{C-\} as its Meta key in Vi state.  @xref{Vi State}, for
viper.texi(,314) more info.@refill
viper.texi(,315) 
viper.texi(,316) Emacs is structured as a lisp interpreter around a C core.  Emacs keys
viper.texi(,317) cause lisp functions to be called.  It is possible to call these
viper.texi(,318) functions directly, by typing @kbd{M-x function-name}.
viper.texi(,319) 
viper.texi(,320) @node Loading Viper, States in Viper, Emacs Preliminaries, Overview
viper.texi(,321) @section Loading Viper
viper.texi(,322) 
viper.texi(,323) The most common way to load it automatically is to include the following
viper.texi(,324) lines (in the given order!):
viper.texi(,325) 
viper.texi(,326) @lisp
viper.texi(,327) (setq viper-mode t)
viper.texi(,328) (require 'viper)
viper.texi(,329) @end lisp
viper.texi(,330) 
viper.texi(,331) @noindent
viper.texi(,332) in your @file{~/.emacs} file.  The @file{.emacs} file is placed in your
viper.texi(,333) home directory and it is be executed every time you invoke Emacs.  This is
viper.texi(,334) the place where all general Emacs customization takes place.  Beginning with
viper.texi(,335) version 20.0, Emacsen have an interactive interface, which simplifies the
viper.texi(,336) job of customization significantly.
viper.texi(,337) 
viper.texi(,338) Viper also uses the file @file{~/.viper} for Viper-specific customization.
viper.texi(,339) The location of Viper customization file can be changed by setting the
viper.texi(,340) variable @code{viper-custom-file-name} in @file{.emacs} @emph{prior} to loading
viper.texi(,341) Viper.
viper.texi(,342) 
viper.texi(,343) The latest versions of Emacs have an interactive customization facility,
viper.texi(,344) which allows you to (mostly) bypass the use of the @file{.emacs} and
viper.texi(,345) @file{.viper} files. You can reach this customization
viper.texi(,346) facility from within Viper's VI state by executing the Ex command
viper.texi(,347) @kbd{:customize}.
viper.texi(,348) 
viper.texi(,349) Once invoked, Viper will arrange to bring up Emacs buffers in Vi state
viper.texi(,350) whenever this makes sense.
viper.texi(,351) @xref{Packages that Change Keymaps}, to find out when forcing Vi command state
viper.texi(,352) on a buffer may be counter-productive.
viper.texi(,353) 
viper.texi(,354) Even if your @file{.emacs} file does not invoke Viper automatically,
viper.texi(,355) you can still load Viper and enter the Vi command state by typing the
viper.texi(,356) following from within Emacs:
viper.texi(,357) 
viper.texi(,358) @lisp
viper.texi(,359) M-x viper-mode
viper.texi(,360) @end lisp
viper.texi(,361) 
viper.texi(,362) When Emacs first comes up, if you have not specified a file on the
viper.texi(,363) command line, it will show the @samp{*scratch*} buffer, in the
viper.texi(,364) @samp{Lisp Interaction} mode.  After you invoke Viper, you can start
viper.texi(,365) editing files by using @kbd{:e}, @kbd{:vi}, or @kbd{v} commands.
viper.texi(,366) (@xref{File and Buffer Handling}, for more information on @kbd{v} and other
viper.texi(,367) new commands that, in many cases, are more convenient than @kbd{:e},
viper.texi(,368) @kbd{:vi}, and similar old-style Vi commands.)@refill
viper.texi(,369) 
viper.texi(,370) Finally, if at some point you would want to de-Viperize your running
viper.texi(,371) copy of Emacs after Viper has been loaded, the command @kbd{M-x
viper.texi(,372) viper-go-away} will do it for you.  The function @code{toggle-viper-mode}
viper.texi(,373) toggles Viperization of Emacs on and off.
viper.texi(,374) 
viper.texi(,375) @node States in Viper, The Minibuffer, Loading Viper,Overview
viper.texi(,376) @section States in Viper
viper.texi(,377) 
viper.texi(,378) @kindex @kbd{C-z}
viper.texi(,379) @kindex @key{ESC}
viper.texi(,380) @kindex @kbd{i}
viper.texi(,381) @cindex Emacs state
viper.texi(,382) @cindex Vi state
viper.texi(,383) @cindex Insert state
viper.texi(,384) @cindex Replace state
viper.texi(,385) @cindex Ex commands
viper.texi(,386) @findex @code{viper-go-away}
viper.texi(,387) @findex @code{toggle-viper-mode}
viper.texi(,388) 
viper.texi(,389) Viper has four states, Emacs, Vi, Insert, and Replace.
viper.texi(,390) 
viper.texi(,391) @table @samp
viper.texi(,392) @item Emacs state
viper.texi(,393) This is the state plain vanilla Emacs is normally in.  After you have loaded
viper.texi(,394) Viper, @kbd{C-z} will normally take you to Vi command state.  Another
viper.texi(,395) @kbd{C-z} will take you back to Emacs state.  This toggle key can be
viper.texi(,396) changed, @pxref{Customization} You can also type @kbd{M-x viper-mode} to
viper.texi(,397) change to Vi state.@refill
viper.texi(,398) 
viper.texi(,399) 
viper.texi(,400) For users who chose to set their user level to 1 at Viper setup time,
viper.texi(,401) switching to Emacs state is deliberately made harder in order to not
viper.texi(,402) confuse the novice user.  In this case, @kbd{C-z} will either iconify Emacs
viper.texi(,403) (if Emacs runs as an application under X) or it will stop Emacs (if
viper.texi(,404) Emacs runs on a dumb terminal or in an Xterm window).
viper.texi(,405) 
viper.texi(,406) @item Vi state
viper.texi(,407) This is the Vi command mode.  Any of the Vi commands, such as @kbd{i, o, a},
viper.texi(,408) @dots{}, will take you to Insert state.  All Vi commands may
viper.texi(,409) be used in this mode.  Most Ex commands can also be used.
viper.texi(,410) For a full list of Ex commands supported by Viper, type
viper.texi(,411) @kbd{:} and then @key{TAB}.  To get help on any issue, including the Ex
viper.texi(,412) commands, type @kbd{:help}.  This will invoke Viper Info
viper.texi(,413) (if it is installed).  Then typing @kbd{i} will prompt you for a topic to
viper.texi(,414) search in the index.  Note: to search for Ex commands in the index, you
viper.texi(,415) should start them with a @kbd{:}, e.g., @kbd{:WW}.
viper.texi(,416) 
viper.texi(,417) In Viper, Ex commands can be made to work on the current Emacs region.
viper.texi(,418) This is done by typing a digit argument before @kbd{:}.
viper.texi(,419) For instance, typing @kbd{1:} will propmt you with something like
viper.texi(,420) @emph{:123,135}, assuming that the current region starts at line 123 and
viper.texi(,421) ends at line 135.  There is no need to type the line numbers, since Viper
viper.texi(,422) inserts them automatically in front of the Ex command.
viper.texi(,423) 
viper.texi(,424) @item Insert state
viper.texi(,425) Insert state is the Vi insertion mode.  @key{ESC} will take you back to
viper.texi(,426) Vi state.  Insert state editing can be done, including auto-indentation.  By
viper.texi(,427) default, Viper disables Emacs key bindings in Insert state.
viper.texi(,428) 
viper.texi(,429) @item Replace state
viper.texi(,430) Commands like @kbd{cw} invoke the Replace state.  When you cross the
viper.texi(,431) boundary of a replacement region (usually designated via a @samp{$} sign),
viper.texi(,432) it will automatically change to Insert state.  You do not have to worry
viper.texi(,433) about it.  The key bindings remain practically the same as in Insert
viper.texi(,434) state.  If you type @key{ESC}, Viper will switch to Vi command mode, terminating the
viper.texi(,435) replacement state.@refill
viper.texi(,436) @end table
viper.texi(,437) 
viper.texi(,438) @cindex mode line
viper.texi(,439) 
viper.texi(,440) The modes are indicated on the @dfn{mode line} as <E>, <I>, <V>, and <R>,
viper.texi(,441) so that the multiple modes do not confuse you.  Most of your editing can be
viper.texi(,442) done in Vi and Insert states.  Viper will try to make all new buffers be in Vi
viper.texi(,443) state, but sometimes they may come up in Emacs state.  @kbd{C-z}
viper.texi(,444) will take you to Vi state in such a case.  In some major modes, like Dired,
viper.texi(,445) Info, Gnus, etc., you should not switch to Vi state (and Viper will not
viper.texi(,446) attempt to do so) because these modes are not intended for text editing and
viper.texi(,447) many of the Vi keys have special meaning there.  If you plan to read news,
viper.texi(,448) browse directories, read mail, etc., from Emacs (which you should start
viper.texi(,449) doing soon!), you should learn about the meaning of the various keys in
viper.texi(,450) those special modes (typing @kbd{C-h m} in a buffer provides
viper.texi(,451) help with key bindings for the major mode of that buffer).
viper.texi(,452) 
viper.texi(,453) If you switch to Vi in Dired or similar modes---no harm is done.  It is just
viper.texi(,454) that the special key bindings provided by those modes will be temporarily
viper.texi(,455) overshadowed by Viper's bindings.  Switching back to Viper's Emacs state
viper.texi(,456) will revive the environment provided by the current major mode.
viper.texi(,457) 
viper.texi(,458) States in Viper are orthogonal to Emacs major modes, such as C mode or Dired
viper.texi(,459) mode.  You can turn Viper on and off for any Emacs state.  When Viper is turned
viper.texi(,460) on, Vi state can be used to move around.  In Insert state, the bindings for
viper.texi(,461) these modes can be accessed.  For beginners (users at Viper levels 1 and 2),
viper.texi(,462) these bindings are suppressed in Insert state, so that new users are not
viper.texi(,463) confused by the Emacs states.  Note that unless you allow Emacs bindings in
viper.texi(,464) Insert state, you cannot do many interesting things, like language
viper.texi(,465) sensitive editing.  For the novice user (at Viper level 1), all major mode
viper.texi(,466) bindings are turned off in Vi state as well.  This includes the bindings for
viper.texi(,467) key sequences that start with @kbd{C-c}, which practically means that all
viper.texi(,468) major mode bindings are unsupported.  @xref{Customization}, to find out how
viper.texi(,469) to allow Emacs keys in Insert state.
viper.texi(,470) 
viper.texi(,471) @menu
viper.texi(,472) * Emacs State::         This is the state you should learn more about when
viper.texi(,473)                         you get up to speed with Viper.
viper.texi(,474) * Vi State::            Vi commands are executed in this state.
viper.texi(,475) * Insert State::        You can enter text, and also can do sophisticated
viper.texi(,476)                         editing if you know enough Emacs commands.
viper.texi(,477) * Replace State::       Like Insert mode, but it is invoked via the
viper.texi(,478)                         replacement commands, such as cw, C, R, etc.
viper.texi(,479) @end menu
viper.texi(,480) 
viper.texi(,481) @node Emacs State, Vi State, States in Viper, States in Viper
viper.texi(,482) @subsection Emacs State
viper.texi(,483) 
viper.texi(,484) @kindex @kbd{C-z}
viper.texi(,485) @cindex Emacs state
viper.texi(,486) 
viper.texi(,487) 
viper.texi(,488) You will be in this mode only by accident (hopefully).  This is the state
viper.texi(,489) Emacs is normally in (imagine!!).  Now leave it as soon as possible by
viper.texi(,490) typing @kbd{C-z}.  Then you will be in Vi state (sigh of relief) :-).
viper.texi(,491) 
viper.texi(,492) Emacs state is actually a Viperism to denote all the major and minor modes
viper.texi(,493) (@pxref{Emacs Preliminaries}) other than Viper that Emacs can be in.  Emacs
viper.texi(,494) can have several modes, such as C mode for editing C programs, LaTeX mode
viper.texi(,495) for editing LaTeX documents, Dired for directory editing, etc.  These are
viper.texi(,496) major modes, each with a different set of key-bindings.  Viper states are
viper.texi(,497) orthogonal to these Emacs major modes.  The presence of these language
viper.texi(,498) sensitive and other modes is a major win over Vi.  @xref{Improvements over
viper.texi(,499) Vi}, for more.@refill
viper.texi(,500) 
viper.texi(,501) The bindings for these modes can be made available in the Viper Insert state
viper.texi(,502) as well as in Emacs state.  Unless you specify your user level as 1 (a
viper.texi(,503) novice), all major mode key sequences that start with @kbd{C-x} and
viper.texi(,504) @kbd{C-c} are also available in Vi state.  This is important because major
viper.texi(,505) modes designed for editing files, such as cc-mode or latex-mode, use key
viper.texi(,506) sequences that begin with @kbd{C-x} and @kbd{C-c}.
viper.texi(,507) 
viper.texi(,508) There is also a key that lets you temporarily escape to Vi command state
viper.texi(,509) from Emacs or Insert states: typing @kbd{C-c \} will let you execute a
viper.texi(,510) single Vi command while staying in Viper's Emacs or Insert state.
viper.texi(,511) In Insert state, the same can also be achieved by typing @kbd{C-z}.
viper.texi(,512) 
viper.texi(,513) 
viper.texi(,514) @node Vi State, Insert State, Emacs State, States in Viper
viper.texi(,515) @subsection Vi State
viper.texi(,516) 
viper.texi(,517) @cindex Vi state
viper.texi(,518) 
viper.texi(,519) This is the Vi command mode.  When Viper is in Vi state, you will see the sign
viper.texi(,520) <V> in the mode line.  Most keys will work as in Vi.  The notable
viper.texi(,521) exceptions are:
viper.texi(,522) 
viper.texi(,523) @table @kbd
viper.texi(,524) @item C-x
viper.texi(,525) @kindex @kbd{C-x}
viper.texi(,526) @kbd{C-x} is used to invoke Emacs commands, mainly those that do window
viper.texi(,527) management.  @kbd{C-x 2} will split a window, @kbd{C-x 0} will close a
viper.texi(,528) window.  @kbd{C-x 1} will close all other windows.  @kbd{C-xb} is used to
viper.texi(,529) switch buffers in a window, and @kbd{C-xo} to move through windows.
viper.texi(,530) These are about the only necessary keystrokes.
viper.texi(,531) For the rest, see the GNU Emacs Manual.
viper.texi(,532) 
viper.texi(,533) @item C-c
viper.texi(,534) @kindex @kbd{C-c}
viper.texi(,535) For user levels 2 and higher, this key serves as a prefix key for the key
viper.texi(,536) sequences used by various major modes.  For users at Viper level 1, @kbd{C-c}
viper.texi(,537) simply beeps.
viper.texi(,538) 
viper.texi(,539) @item C-g and C-]
viper.texi(,540) @kindex @kbd{C-g}
viper.texi(,541) @kindex @kbd{C-]}
viper.texi(,542) 
viper.texi(,543) These are the Emacs @samp{quit} keys.
viper.texi(,544) There will be cases where you will have to
viper.texi(,545) use @kbd{C-g} to quit.  Similarly, @kbd{C-]} is used to exit
viper.texi(,546) @samp{Recursive Edits} in Emacs for which there is no comparable Vi
viper.texi(,547) functionality and no key-binding.  Recursive edits are indicated by
viper.texi(,548) @samp{[]} brackets framing the modes on the mode line.
viper.texi(,549) @xref{Recursive Edit,Recursive
viper.texi(,550) Edit,Recursive Edit,emacs,The GNU Emacs Manual}.
viper.texi(,551) At user level 1, @kbd{C-g} is bound to @code{viper-info-on-file}
viper.texi(,552) function instead.
viper.texi(,553) @refill
viper.texi(,554) @item C-\
viper.texi(,555) @kindex @kbd{C-\}
viper.texi(,556) @cindex Meta key
viper.texi(,557) 
viper.texi(,558) Viper uses @key{ESC} as a switch between Insert and Vi states.  Emacs uses
viper.texi(,559) @key{ESC} for Meta.  The Meta key is very important in Emacs since many
viper.texi(,560) functions are accessible only via that key as @kbd{M-x function-name}.
viper.texi(,561) Therefore, we need to simulate it somehow.  In Viper's Vi, Insert, and
viper.texi(,562) Replace states, the meta key is set to be @kbd{C-\}.  Thus, to get
viper.texi(,563) @kbd{M-x}, you should type @kbd{C-\ x} (if the keyboard has no Meta key,
viper.texi(,564) which is rare these days).
viper.texi(,565) This works both in the Vi command state and in the Insert and Replace
viper.texi(,566) states.  In Vi command state, you can also use @kbd{\ @key{ESC}} as the
viper.texi(,567) meta key.
viper.texi(,568) 
viper.texi(,569) Note: Emacs binds @kbd{C-\} to a function that offers to change the
viper.texi(,570) keyboard input method in the multilingual environment.  Viper overrides this
viper.texi(,571) binding.  However, it is still possible to switch the input method by typing
viper.texi(,572) @kbd{\ C-\} in the Vi command state and @kbd{C-z \ C-\} in the Insert state.
viper.texi(,573) Or you can use the MULE menu in the menubar.
viper.texi(,574) @end table
viper.texi(,575) @noindent
viper.texi(,576) Other differences are mostly improvements.  The ones you should know
viper.texi(,577) about are:
viper.texi(,578) 
viper.texi(,579) @table @samp
viper.texi(,580) @item Undo
viper.texi(,581) @kindex @kbd{u}
viper.texi(,582) @kbd{u} will undo.  Undo can be repeated by the @kbd{.} key.  Undo itself
viper.texi(,583) can be undone.  Another @kbd{u} will change the direction.  The presence
viper.texi(,584) of repeatable undo means that @kbd{U}, undoing lines, is not very
viper.texi(,585) important.  Therefore, @kbd{U} also calls @code{viper-undo}.
viper.texi(,586) @cindex multiple undo
viper.texi(,587) @cindex undo
viper.texi(,588) 
viper.texi(,589) 
viper.texi(,590) @item Counts
viper.texi(,591) Most commands, @kbd{~}, @kbd{[[}, @kbd{p}, @kbd{/}, @dots{}, etc., take counts.
viper.texi(,592) 
viper.texi(,593) @comment ]] Just to balance parens
viper.texi(,594) @item Regexps
viper.texi(,595) Viper uses Emacs Regular Expressions for searches.  These are a superset of
viper.texi(,596) Vi regular
viper.texi(,597) expressions, excepting the change-of-case escapes @samp{\u}, @samp{\L},
viper.texi(,598) @dots{}, etc.  @xref{Regular Expressions,,Regular Expressions,emacs,The
viper.texi(,599) GNU Emacs Manual}, for details.
viper.texi(,600) Files specified to @kbd{:e} use @code{csh} regular expressions
viper.texi(,601) (globbing, wildcards, what have you).
viper.texi(,602) However, the function @code{viper-toggle-search-style}, bound to @kbd{C-c /},
viper.texi(,603) lets the user switch from search with regular expressions to plain vanilla
viper.texi(,604) search and vice versa.  It also lets one switch from case-sensitive search
viper.texi(,605) to case-insensitive and back.
viper.texi(,606) @xref{Viper Specials}, for more details.
viper.texi(,607) @cindex regular expressions
viper.texi(,608) @cindex vanilla search
viper.texi(,609) @cindex case-sensitive search
viper.texi(,610) @cindex case-insensitive search
viper.texi(,611) @kindex @kbd{C-c /}
viper.texi(,612) 
viper.texi(,613) @item Ex commands
viper.texi(,614) @cindex Ex commands
viper.texi(,615) The current working directory of a buffer is automatically inserted in the
viper.texi(,616) minibuffer if you type @kbd{:e} then space.  Absolute filenames are
viper.texi(,617) required less often in Viper.  For file names, Emacs uses a convention that
viper.texi(,618) is slightly different from other programs.  It is designed to minimize the
viper.texi(,619) need for deleting file names that Emacs provides in its prompts.  (This is
viper.texi(,620) usually convenient, but occasionally the prompt may suggest a wrong file
viper.texi(,621) name for you.)  If you see a prompt @kbd{/usr/foo/} and you wish to edit the
viper.texi(,622) file @kbd{~/.viper}, you don't have to erase the prompt.  Instead, simply
viper.texi(,623) continue typing what you need.  Emacs will interpret @kbd{/usr/foo/~/.viper}
viper.texi(,624) correctly.  Similarly, if the prompt is @kbd{~/foo/} and you need to get to
viper.texi(,625) @kbd{/bar/file}, keep typing.  Emacs interprets @kbd{~/foo//bar/} as
viper.texi(,626) @kbd{/bar/file}, since when it sees @samp{//}, it understands that
viper.texi(,627) @kbd{~/foo/} is to be discarded.
viper.texi(,628) 
viper.texi(,629) The command @kbd{:cd} will change the default directory for the
viper.texi(,630) current buffer.  The command @kbd{:e} will interpret the
viper.texi(,631) filename argument in @code{csh}.  @xref{Customization}, if you
viper.texi(,632) want to change the default shell.
viper.texi(,633) The command @kbd{:next} takes counts from
viper.texi(,634) @kbd{:args}, so that @kbd{:rew} is obsolete.  Also, @kbd{:args} will show only
viper.texi(,635) the invisible files (i.e., those that are not currently seen in Emacs
viper.texi(,636) windows).
viper.texi(,637) 
viper.texi(,638) When applicable, Ex commands support file completion and history.  This
viper.texi(,639) means that by typing a partial file name and then @key{TAB}, Emacs will try
viper.texi(,640) to complete the name or it will offer a menu of possible completions.
viper.texi(,641) This works similarly to Tcsh and extends the behavior of Csh.  While Emacs
viper.texi(,642) is waiting for a file name, you can type @kbd{M-p} to get the previous file
viper.texi(,643) name you typed.  Repeatedly typing @kbd{M-p} and @kbd{M-n} will let you
viper.texi(,644) browse through the file history.
viper.texi(,645) 
viper.texi(,646) Like file names, partially typed Ex commands can be completed by typing
viper.texi(,647) @key{TAB}, and Viper keeps the history of Ex commands.  After typing
viper.texi(,648) @kbd{:}, you can browse through the previously entered Ex commands by
viper.texi(,649) typing @kbd{M-p} and @kbd{M-n}.  Viper tries to rationalize when it puts Ex
viper.texi(,650) commands on the history list.  For instance, if you typed @kbd{:w!@: foo},
viper.texi(,651) only @kbd{:w!} will be placed on the history list.  This is because the
viper.texi(,652) last history element is the default that can be invoked simply by typing
viper.texi(,653) @kbd{: @key{RET}}.  If @kbd{:w!@: foo} were placed on the list, it would be all to
viper.texi(,654) easy to override valuable data in another file.  Reconstructing the full
viper.texi(,655) command, @kbd{:w!@: foo}, from the history is still not that hard, since Viper
viper.texi(,656) has a separate history for file names.  By typing @kbd{: M-p}, you will get
viper.texi(,657) @kbd{:w!} in the Minibuffer.  Then, repeated @kbd{M-p} will get you through
viper.texi(,658) the file history, inserting one file name after another.
viper.texi(,659) 
viper.texi(,660) In contrast to @kbd{:w!@: foo}, if the command were @kbd{:r foo}, the entire
viper.texi(,661) command will appear in the history list.  This is because having @kbd{:r}
viper.texi(,662) alone as a default is meaningless, since this command requires a file
viper.texi(,663) argument.
viper.texi(,664) @refill
viper.texi(,665) @end table
viper.texi(,666) @noindent
viper.texi(,667) As Vi, Viper's destructive commands can be re-executed by typing `@kbd{.}'.
viper.texi(,668) However, in addition, Viper keeps track of the history of such commands.  This
viper.texi(,669) history can be perused by typing @kbd{C-c M-p} and @kbd{C-c M-n}.
viper.texi(,670) Having found the appropriate command, it can be then executed by typing
viper.texi(,671) `@kbd{.}'.
viper.texi(,672) @xref{Improvements over Vi}, for more information.
viper.texi(,673) 
viper.texi(,674) @node Insert State, Replace State, Vi State, States in Viper
viper.texi(,675) @subsection Insert State
viper.texi(,676) 
viper.texi(,677) @cindex Insert state
viper.texi(,678) 
viper.texi(,679) To avoid confusing the beginner (at Viper level 1 and 2), Viper makes only the
viper.texi(,680) standard Vi keys available in Insert state.  The implication is that
viper.texi(,681) Emacs major modes cannot be used in Insert state.
viper.texi(,682) It is strongly recommended that as soon as you are comfortable, make the
viper.texi(,683) Emacs state bindings visible (by changing your user level to 3 or higher).
viper.texi(,684) @xref{Customization},
viper.texi(,685) to see how to do this.@refill
viper.texi(,686) 
viper.texi(,687) Once this is done, it is possible to do quite a bit of editing in
viper.texi(,688) Insert state.  For instance, Emacs has a @dfn{yank} command, @kbd{C-y},
viper.texi(,689) which is similar to Vi's @kbd{p}.  However, unlike @kbd{p}, @kbd{C-y} can be
viper.texi(,690) used in Insert state of Viper.  Emacs also has a kill ring where it keeps
viper.texi(,691) pieces of text you deleted while editing buffers.  The command @kbd{M-y} is
viper.texi(,692) used to delete the text previously put back by Emacs' @kbd{C-y} or by Vi's
viper.texi(,693) @kbd{p} command and reinsert text that was placed on the kill-ring earlier.
viper.texi(,694) 
viper.texi(,695) This works both in Vi and Insert states.
viper.texi(,696) In Vi state, @kbd{M-y} is a much better alternative to the usual Vi's way
viper.texi(,697) of recovering the 10 previously deleted chunks of text.  In Insert state,
viper.texi(,698) you can
viper.texi(,699) use this as follows.  Suppose you deleted a piece of text and now you need
viper.texi(,700) to re-insert it while editing in Insert mode.  The key @kbd{C-y} will put
viper.texi(,701) back the most recently deleted chunk.  If this is not what you want, type
viper.texi(,702) @kbd{M-y} repeatedly and, hopefully, you will find the chunk you want.
viper.texi(,703) 
viper.texi(,704) Finally, in Insert and Replace states, Viper provides the history of
viper.texi(,705) pieces of text inserted in previous insert or replace commands.  These
viper.texi(,706) strings of text can be recovered by repeatedly typing @kbd{C-c M-p} or
viper.texi(,707) @kbd{C-c M-n} while in Insert or Replace state.  (This feature is disabled
viper.texi(,708) in the minibuffer: the above keys are usually bound to other histories,
viper.texi(,709) which are more appropriate in the minibuffer.)
viper.texi(,710) 
viper.texi(,711) 
viper.texi(,712) @cindex Meta key
viper.texi(,713) 
viper.texi(,714) You can call Meta functions from Insert state.  As in Vi state, the Meta key
viper.texi(,715) is @kbd{C-\}.  Thus @kbd{M-x} is typed as @kbd{C-\ x}.
viper.texi(,716) 
viper.texi(,717) Other Emacs commands that are useful in Insert state are @kbd{C-e}
viper.texi(,718) and @kbd{C-a}, which move the cursor to the end and the beginning of the
viper.texi(,719) current line, respectively.  You can also use @kbd{M-f} and @kbd{M-b},
viper.texi(,720) which move the cursor forward (or backward) one word.
viper.texi(,721) If your display has a Meta key, these functions are invoked by holding the
viper.texi(,722) Meta key and then typing @kbd{f} and @kbd{b}, respectively.  On displays
viper.texi(,723) without the Meta key, these functions are invoked by typing
viper.texi(,724) @kbd{C-\ f} and @kbd{C-\ b} (@kbd{C-\} simulates the Meta key in Insert
viper.texi(,725) state, as explained above).
viper.texi(,726) 
viper.texi(,727) The key @kbd{C-z} is sometimes also useful in Insert state: it allows you
viper.texi(,728) to execute a single command in Vi state without leaving the Insert state!
viper.texi(,729) For instance, @kbd{C-z d2w} will delete the next two words without leaving
viper.texi(,730) the Insert state.
viper.texi(,731) 
viper.texi(,732) When Viper is in Insert state, you will see <I> in the mode line.
viper.texi(,733) 
viper.texi(,734) @node Replace State,, Insert State, States in Viper
viper.texi(,735) @subsection Replace State
viper.texi(,736) 
viper.texi(,737) @cindex Replace state
viper.texi(,738) 
viper.texi(,739) This state is entered through Vi replacement commands, such as @kbd{C},
viper.texi(,740) @kbd{cw}, etc., or by typing @kbd{R}.  In Replace state, Viper puts <R> in
viper.texi(,741) the mode line to let you know which state is in effect.  If Replace state is
viper.texi(,742) entered through @kbd{R}, Viper stays in that state until the user hits
viper.texi(,743) @key{ESC}.  If this state is entered via the other replacement commands,
viper.texi(,744) then Replace state is in effect until you hit @key{ESC} or until you cross
viper.texi(,745) the rightmost boundary of the replacement region.  In the latter case, Viper
viper.texi(,746) changes its state from Replace to Insert (which you will notice by the
viper.texi(,747) change in the mode line).
viper.texi(,748) 
viper.texi(,749) Since Viper runs under Emacs, it is possible to switch between buffers
viper.texi(,750) while in Replace state.  You can also move the cursor using the arrow keys
viper.texi(,751) (even on dumb terminals!)@: and the mouse.  Because of this freedom (which is
viper.texi(,752) unattainable in regular Vi), it is possible to take the cursor outside the
viper.texi(,753) replacement region.  (This may be necessary for several reasons, including
viper.texi(,754) the need to enable text selection and region-setting with the mouse.)
viper.texi(,755) 
viper.texi(,756) The issue then arises as to what to do when the user
viper.texi(,757) hits the @key{ESC} key.  In Vi, this would cause the text between cursor and
viper.texi(,758) the end of the replacement region to be deleted.  But what if, as is
viper.texi(,759) possible in Viper, the cursor is not inside the replacement region?
viper.texi(,760) 
viper.texi(,761) To solve the problem, Viper keeps track of the last cursor position while it
viper.texi(,762) was still inside the replacement region.  So, in the above situation, Viper
viper.texi(,763) would delete text between this position and the end of the replacement
viper.texi(,764) region.
viper.texi(,765) 
viper.texi(,766) @node The Minibuffer,Multiple Files in Viper, States in Viper, Overview
viper.texi(,767) @section The Minibuffer
viper.texi(,768) 
viper.texi(,769) @cindex Minibuffer
viper.texi(,770) 
viper.texi(,771) The Minibuffer is where commands are entered in.  Editing can be done
viper.texi(,772) by commands from Insert state, namely:
viper.texi(,773) 
viper.texi(,774) @table @kbd
viper.texi(,775) @item C-h
viper.texi(,776) Backspace
viper.texi(,777) @item C-w
viper.texi(,778) Delete Word
viper.texi(,779) @item C-u
viper.texi(,780) Erase line
viper.texi(,781) @item C-v
viper.texi(,782) Quote the following character
viper.texi(,783) @item @key{RET}
viper.texi(,784) Execute command
viper.texi(,785) @item C-g and C-]
viper.texi(,786) Emacs quit and abort keys.  These may be necessary.  @xref{Vi State}, for an
viper.texi(,787) explanation.
viper.texi(,788) @item M-p and M-n
viper.texi(,789) These keys are bound to functions that peruse minibuffer history.  The
viper.texi(,790) precise history to be perused depends on the context.  It may be the history
viper.texi(,791) of search strings, Ex commands, file names, etc.
viper.texi(,792) @end table
viper.texi(,793) 
viper.texi(,794) Most of the Emacs keys are functional in the Minibuffer.  While in the
viper.texi(,795) Minibuffer, Viper tries to make editing resemble Vi's behavior when the
viper.texi(,796) latter is waiting for the user to type an Ex command.  In particular, you
viper.texi(,797) can use the regular Vi commands to edit the Minibuffer.  You can switch
viper.texi(,798) between the Vi state and Insert state at will, and even use the replace mode.
viper.texi(,799) Initially, the Minibuffer comes up in Insert state.
viper.texi(,800) 
viper.texi(,801) Some users prefer plain Emacs bindings in the Minibuffer.  To this end, set
viper.texi(,802) @code{viper-vi-style-in-minibuffer} to @code{nil} in @file{.viper}.
viper.texi(,803) @xref{Customization}, to learn how to do this.
viper.texi(,804) 
viper.texi(,805) When the Minibuffer changes Viper states, you will notice that the appearance
viper.texi(,806) of the text there changes as well.  This is useful because the Minibuffer
viper.texi(,807) has no mode line to tell which Vi state it is in.
viper.texi(,808) The appearance of the text in the Minibuffer can be changed.
viper.texi(,809) @xref{Viper Specials}, for more details.
viper.texi(,810) 
viper.texi(,811) @node Multiple Files in Viper,Unimplemented Features,The Minibuffer,Overview
viper.texi(,812) @section Multiple Files in Viper
viper.texi(,813) 
viper.texi(,814) @cindex multiple files
viper.texi(,815) @cindex managing multiple files
viper.texi(,816) 
viper.texi(,817) Viper can edit multiple files.  This means, for example that you never need
viper.texi(,818) to suffer through @code{No write since last change} errors.
viper.texi(,819) Some Viper elements are common over all the files.
viper.texi(,820) 
viper.texi(,821) @table @samp
viper.texi(,822) @item Textmarkers
viper.texi(,823) @cindex markers
viper.texi(,824) @cindex textmarkers
viper.texi(,825) Textmarkers remember @emph{files and positions}.
viper.texi(,826) If you set marker @samp{a} in
viper.texi(,827) file @file{foo}, start editing file @file{bar} and type @kbd{'a}, then
viper.texi(,828) @emph{YOU WILL SWITCH TO FILE @file{foo}}.  You can see the contents of a
viper.texi(,829) textmarker using the Viper command @kbd{[<a-z>} where <a-z> are the
viper.texi(,830) textmarkers, e.g., @kbd{[a} to view marker @samp{a} .@refill
viper.texi(,831) @item Repeated Commands
viper.texi(,832) Command repetitions are common over files.  Typing @kbd{!!} will repeat the
viper.texi(,833) last @kbd{!} command whichever file it was issued from.
viper.texi(,834) Typing @kbd{.} will repeat the last command from any file, and
viper.texi(,835) searches will repeat the last search.  Ex commands can be repeated by typing
viper.texi(,836) @kbd{: @key{RET}}.@refill
viper.texi(,837) Note: in some rare cases, that @kbd{: @key{RET}} may do something dangerous.
viper.texi(,838) However, usually its effect can be undone by typing @kbd{u}.
viper.texi(,839) @item Registers
viper.texi(,840) @cindex registers
viper.texi(,841) Registers are common to files.  Also, text yanked with @kbd{y} can be
viper.texi(,842) put back (@kbd{p}) into any file.  The Viper command @kbd{]<a-z>}, where <a-z> are
viper.texi(,843) the registers, can be used to look at the contents of a register, e.g.,
viper.texi(,844) type @kbd{]a} to view register @samp{a}.
viper.texi(,845) 
viper.texi(,846) There is one difference in text deletion that you should be
viper.texi(,847) aware of.  This difference comes from Emacs and was adopted in Viper
viper.texi(,848) because we find it very useful.  In Vi, if you delete a line, say, and then
viper.texi(,849) another line, these two deletions are separated and are put back
viper.texi(,850) separately if you use the @samp{p} command.  In Emacs (and Viper), successive
viper.texi(,851) series of deletions that are @emph{not interrupted} by other commands are
viper.texi(,852) lumped together, so the deleted text gets accumulated and can be put back
viper.texi(,853) as one chunk.  If you want to break a sequence of deletions so that the
viper.texi(,854) newly deleted text could be put back separately from the previously deleted
viper.texi(,855) text, you should perform a non-deleting action, e.g., move the cursor one
viper.texi(,856) character in any direction.
viper.texi(,857) @item Absolute Filenames
viper.texi(,858) @cindex absolute file names
viper.texi(,859) The current directory name for a file is automatically prepended to the
viper.texi(,860) file name in any
viper.texi(,861) @kbd{:e}, @kbd{:r}, @kbd{:w}, etc., command (in Emacs, each buffer has a
viper.texi(,862) current directory).
viper.texi(,863) This directory is inserted in the Minibuffer once you type space after
viper.texi(,864) @kbd{:e, r}, etc.  Viper also supports completion of file names and Ex
viper.texi(,865) commands (@key{TAB}), and it keeps track of
viper.texi(,866) command and file history (@kbd{M-p}, @kbd{M-n}).
viper.texi(,867) Absolute filenames are required less
viper.texi(,868) often in Viper.
viper.texi(,869) 
viper.texi(,870) You should be aware that Emacs interprets @kbd{/foo/bar//bla} as
viper.texi(,871) @kbd{/bla} and @kbd{/foo/~/bar} as @kbd{~/bar}.  This is designed to
viper.texi(,872) minimize the need for erasing file names that Emacs suggests in its
viper.texi(,873) prompts, if a suggested file name is not what you wanted.
viper.texi(,874) 
viper.texi(,875) The command @kbd{:cd} will change the default directory for the
viper.texi(,876) current Emacs buffer.  The Ex command @kbd{:e} will interpret the
viper.texi(,877) filename argument in @samp{csh}, by default.  @xref{Customization}, if you
viper.texi(,878) want to change this.
viper.texi(,879) @end table
viper.texi(,880) 
viper.texi(,881) @noindent
viper.texi(,882) Currently undisplayed files can be listed using the @kbd{:ar} command.  The
viper.texi(,883) command @kbd{:n} can be given counts from the @kbd{:ar} list to switch to
viper.texi(,884) other files. For example, use `:n3' to move to the third file in that list.
viper.texi(,885) 
viper.texi(,886) @node Unimplemented Features,,Multiple Files in Viper,Overview
viper.texi(,887) @section Unimplemented Features
viper.texi(,888) 
viper.texi(,889) Unimplemented features include:
viper.texi(,890) 
viper.texi(,891) @itemize @bullet
viper.texi(,892) @item
viper.texi(,893) @kbd{:ab} and @kbd{:una} are not implemented, since
viper.texi(,894) @kbd{:ab} is considered obsolete, since Emacs has much
viper.texi(,895) more powerful facilities for defining abbreviations.
viper.texi(,896) @item
viper.texi(,897) @kbd{:set option?} is not implemented.  The current
viper.texi(,898) @kbd{:set} can also be used to set Emacs variables.
viper.texi(,899) @item
viper.texi(,900) @kbd{:se list} requires modification of the display code for Emacs, so
viper.texi(,901) it is not implemented.
viper.texi(,902) A useful alternative is @code{cat -t -e file}.  Unfortunately, it cannot
viper.texi(,903) be used directly inside Emacs, since Emacs will obdurately change @samp{^I}
viper.texi(,904) back to normal tabs.@refill
viper.texi(,905) @end itemize
viper.texi(,906) 
viper.texi(,907) @comment  node-name,  next,  previous,  up
viper.texi(,908) @node Improvements over Vi, Customization, Overview, Top
viper.texi(,909) @chapter Improvements over Vi
viper.texi(,910) 
viper.texi(,911) Some common problems with Vi and Ex have been solved in Viper.  This
viper.texi(,912) includes better implementation of existing commands, new commands, and
viper.texi(,913) the facilities provided by Emacs.
viper.texi(,914) 
viper.texi(,915) @menu
viper.texi(,916) * Basics::                  Basic Viper differences, Multi-file effects.
viper.texi(,917) * Undo and Backups::        Multiple undo, auto-save, backups and changes
viper.texi(,918) * History::                 History for Ex and Vi commands.
viper.texi(,919) * Macros and Registers::    Keyboard Macros (extended ".")@: @@reg execution.
viper.texi(,920) * Completion::              Filename and Command Completion for Ex.
viper.texi(,921) * Improved Search::         Incremental Search and Buffer Content Search.
viper.texi(,922) * Abbreviation Facilities:: Normal Abbrevs, Templates, and Dynamic Abbrevs.
viper.texi(,923) * Movement and Markers::    Screen Editor movements, viewing textmarkers.
viper.texi(,924) * New Commands::            Commands that do not exist in Vi.
viper.texi(,925) * Useful Packages::         A Sampling of some Emacs packages, and things
viper.texi(,926)                             you should know about.
viper.texi(,927) @end menu
viper.texi(,928) 
viper.texi(,929) @node Basics, Undo and Backups, Improvements over Vi, Improvements over Vi
viper.texi(,930) @section Basics
viper.texi(,931) 
viper.texi(,932) The Vi command set is based on the idea of combining motion commands
viper.texi(,933) with other commands.  The motion command is used as a text region
viper.texi(,934) specifier for other commands.
viper.texi(,935) We classify motion commands into @dfn{point commands} and
viper.texi(,936) @dfn{line commands}.@refill
viper.texi(,937) 
viper.texi(,938) @cindex point commands
viper.texi(,939) 
viper.texi(,940) The point commands are:
viper.texi(,941) 
viper.texi(,942) @quotation
viper.texi(,943) @kbd{h}, @kbd{l}, @kbd{0},  @kbd{$}, @kbd{w}, @kbd{W}, @kbd{b}, @kbd{B},
viper.texi(,944) @kbd{e}, @kbd{E}, @kbd{(}, @kbd{)}, @kbd{/}, @kbd{?}, @kbd{`}, @kbd{f},
viper.texi(,945) @kbd{F}, @kbd{t}, @kbd{T}, @kbd{%}, @kbd{;}, @kbd{,}, @kbd{^}
viper.texi(,946) @end quotation
viper.texi(,947) 
viper.texi(,948) @cindex line commands
viper.texi(,949) 
viper.texi(,950) The line commands are:
viper.texi(,951) 
viper.texi(,952) @quotation
viper.texi(,953) @kbd{j}, @kbd{k}, @kbd{+}, @kbd{-}, @kbd{H}, @kbd{M}, @kbd{L}, @kbd{@{},
viper.texi(,954) @kbd{@}}, @kbd{G}, @kbd{'},  @kbd{[[}, @kbd{]]}, @kbd{[]}
viper.texi(,955) @end quotation
viper.texi(,956) 
viper.texi(,957) @cindex region
viper.texi(,958) @cindex region specification
viper.texi(,959) @cindex expanding (region)
viper.texi(,960) @cindex describing regions
viper.texi(,961) @cindex movement commands
viper.texi(,962) 
viper.texi(,963) @noindent
viper.texi(,964) If a point command is given as an argument to a modifying command, the
viper.texi(,965) region determined by the point command will be affected by the modifying
viper.texi(,966) command.  On the other hand, if a line command is given as an argument to a
viper.texi(,967) modifying command, the region determined by the line command will be
viper.texi(,968) enlarged so that it will become the smallest region properly containing the
viper.texi(,969) region and consisting of whole lines (we call this process @dfn{expanding
viper.texi(,970) the region}), and then the enlarged region will be affected by the modifying
viper.texi(,971) command.
viper.texi(,972) Text Deletion Commands (@pxref{Deleting Text}), Change commands
viper.texi(,973) (@pxref{Changing Text}), even Shell Commands (@pxref{Shell Commands})
viper.texi(,974) use these commands to describe a region of text to operate on.
viper.texi(,975) Thus, type @kbd{dw} to delete a word, @kbd{>@}} to shift a paragraph, or
viper.texi(,976) @kbd{!'afmt} to format a region from @samp{point} to textmarker
viper.texi(,977) @samp{a}.
viper.texi(,978) 
viper.texi(,979) @cindex r and R region specifiers
viper.texi(,980) 
viper.texi(,981) Viper adds the region specifiers @samp{r} and @samp{R}.  Emacs has a
viper.texi(,982) special marker called @dfn{mark}.  The text-area between the current cursor
viper.texi(,983) position @dfn{point} and the @dfn{mark} is called the @dfn{region}.
viper.texi(,984) @samp{r} specifies the raw region and @samp{R} is the expanded region
viper.texi(,985) (i.e., the minimal contiguous chunk of full lines that contains the raw
viper.texi(,986) region).
viper.texi(,987) @kbd{dr} will now delete the region, @kbd{>r} will shift it, etc.
viper.texi(,988) @kbd{r,R} are not motion commands, however.  The special mark is set by
viper.texi(,989) @kbd{m.} and other commands.  @xref{Marking}, for more info.
viper.texi(,990) 
viper.texi(,991) Viper also adds counts to most commands for which it would make sense.
viper.texi(,992) 
viper.texi(,993) In the Overview chapter, some Multiple File issues were discussed
viper.texi(,994) (@pxref{Multiple Files in Viper}).  In addition to the files, Emacs has
viper.texi(,995) buffers.  These can be seen in the @kbd{:args} list and switched using
viper.texi(,996) @kbd{:next} if you type @kbd{:set ex-cycle-through-non-files t}, or
viper.texi(,997) specify @code{(setq ex-cycle-through-non-files t)} in your @file{.viper}
viper.texi(,998) file.  @xref{Customization}, for details.
viper.texi(,999) 
viper.texi(,1000) @node Undo and Backups, History, Basics, Improvements over Vi
viper.texi(,1001) @section Undo and Backups
viper.texi(,1002) 
viper.texi(,1003) @cindex undo
viper.texi(,1004) 
viper.texi(,1005) Viper provides multiple undo.  The number of undo's and the size is limited
viper.texi(,1006) by the machine.  The Viper command @kbd{u} does an undo.  Undo can be
viper.texi(,1007) repeated by typing @kbd{.} (a period).  Another @kbd{u} will undo the undo,
viper.texi(,1008) and further
viper.texi(,1009) @kbd{.} will repeat it.  Typing @kbd{u} does the first undo, and changes the
viper.texi(,1010) direction.
viper.texi(,1011) 
viper.texi(,1012) @cindex backup files
viper.texi(,1013) @cindex auto save
viper.texi(,1014) 
viper.texi(,1015) Since the undo size is limited, Viper can create backup files and
viper.texi(,1016) auto-save files.  It will normally do this automatically.  It is possible
viper.texi(,1017) to have numbered backups, etc.  For details, @pxref{Backup,,Backup and
viper.texi(,1018) Auto-Save,emacs,The GNU Emacs Manual} @refill
viper.texi(,1019) 
viper.texi(,1020) @comment [ balance parens
viper.texi(,1021) @cindex viewing registers and markers
viper.texi(,1022) @cindex registers
viper.texi(,1023) @cindex markers
viper.texi(,1024) @cindex textmarkers
viper.texi(,1025) 
viper.texi(,1026) The results of the 9 previous changes are available in the 9 numeric
viper.texi(,1027) registers, as in Vi.  The extra goody is the ability to @emph{view} these
viper.texi(,1028) registers, in addition to being able to access them through @kbd{p} and
viper.texi(,1029) @kbd{M-y} (@xref{Insert State}, for details.)
viper.texi(,1030) The Viper command @kbd{] register} will display the contents of any
viper.texi(,1031) register, numeric or alphabetical.  The related command @kbd{[ textmarker}
viper.texi(,1032) will show the text around the textmarker.  @samp{register} and @samp{textmarker}
viper.texi(,1033) can be any letters from a through z.
viper.texi(,1034) @comment ] balance parens
viper.texi(,1035) 
viper.texi(,1036) @node History,  Macros and Registers, Undo and Backups,Improvements over Vi
viper.texi(,1037) @section History
viper.texi(,1038) 
viper.texi(,1039) @cindex history
viper.texi(,1040) @cindex Minibuffer
viper.texi(,1041) 
viper.texi(,1042) History is provided for Ex commands, Vi searches, file names, pieces of
viper.texi(,1043) text inserted in earlier commands that use Insert or Replace state, and for
viper.texi(,1044) destructive commands in Vi state.  These are
viper.texi(,1045) useful for fixing those small typos that screw up searches and @kbd{:s},
viper.texi(,1046) and for eliminating routine associated with repeated typing of file names
viper.texi(,1047) or pieces of text that need to be inserted frequently.
viper.texi(,1048) At the @kbd{:} or @kbd{/} prompts in the Minibuffer, you can do the following:
viper.texi(,1049) 
viper.texi(,1050) @table @kbd
viper.texi(,1051) @item M-p and M-n
viper.texi(,1052) To move to previous and next history items.  This causes the history
viper.texi(,1053) items to appear on the command line, where you can edit them, or
viper.texi(,1054) simply type Return to execute.
viper.texi(,1055) @item M-r and M-s
viper.texi(,1056) To search backward and forward through the history.
viper.texi(,1057) @item @key{RET}
viper.texi(,1058) Type @key{RET} to accept a default (which is displayed in the prompt).
viper.texi(,1059) @end table
viper.texi(,1060) 
viper.texi(,1061) The history of insertions  can be perused by
viper.texi(,1062) typing @kbd{C-c M-p} and @kbd{C-c M-n} while in Insert or Replace state.
viper.texi(,1063) The history of destructive Vi commands can be perused via the same keys
viper.texi(,1064) when Viper is in Vi state.  @xref{Viper Specials}, for details.
viper.texi(,1065) 
viper.texi(,1066) All Ex commands have a file history.  For instance, typing @kbd{:e}, space
viper.texi(,1067) and then @kbd{M-p} will bring up the name of the previously typed file
viper.texi(,1068) name.  Repeatedly typing @kbd{M-p}, @kbd{M-n}, etc., will let you browse
viper.texi(,1069) through the file history.
viper.texi(,1070) 
viper.texi(,1071) Similarly, commands that have to do with switching buffers
viper.texi(,1072) have a buffer history, and commands that expect strings or regular
viper.texi(,1073) expressions keep a history on those items.
viper.texi(,1074) 
viper.texi(,1075) @node Macros and Registers,Completion,History,Improvements over Vi
viper.texi(,1076) @section Macros and Registers
viper.texi(,1077) 
viper.texi(,1078) @cindex keyboard macros
viper.texi(,1079) @cindex macros
viper.texi(,1080) @cindex registers
viper.texi(,1081) @cindex register execution
viper.texi(,1082) 
viper.texi(,1083) Viper facilitates the use of Emacs-style keyboard macros.  @kbd{@@#} will
viper.texi(,1084) start a macro definition.  As you type, the commands will be executed, and
viper.texi(,1085) remembered (This is called ``learn mode'' in some editors.)
viper.texi(,1086) @kbd{@@register} will complete the macro, putting it into @samp{register},
viper.texi(,1087) where @samp{register} is any character from @samp{a} through @samp{z}.  Then
viper.texi(,1088) you can execute this macro using @kbd{@@register}.  It is, of course,
viper.texi(,1089) possible to yank some text into a register and execute it using
viper.texi(,1090) @kbd{@@register}.  Typing @kbd{@@@@}, @kbd{@@RET}, or @kbd{@@C-j} will
viper.texi(,1091) execute the last macro that was executed using @kbd{@@register}.@refill
viper.texi(,1092) 
viper.texi(,1093) Viper will automatically lowercase the register, so that pressing the
viper.texi(,1094) @kbd{SHIFT} key for @kbd{@@} will not create problems.  This is for
viper.texi(,1095) @kbd{@@} macros and @kbd{"p} @emph{only}.  In the case of @kbd{y},
viper.texi(,1096) @kbd{"Ayy} will append to @emph{register a}.  For @kbd{[,],',`}, it
viper.texi(,1097) is an error to use a Uppercase register name.
viper.texi(,1098) 
viper.texi(,1099) @comment [ balance parens
viper.texi(,1100) @cindex viewing registers and markers
viper.texi(,1101) 
viper.texi(,1102) The contents of a register can be seen by @kbd{]register}.  (@kbd{[textmarker}
viper.texi(,1103) will show the contents of a textmarker).
viper.texi(,1104) @comment ] balance parens
viper.texi(,1105) 
viper.texi(,1106) @cindex last keyboard macro
viper.texi(,1107) 
viper.texi(,1108) The last keyboard macro can also be executed using
viper.texi(,1109) @kbd{*}, and it can be yanked into a register using @kbd{@@!register}.
viper.texi(,1110) This is useful for Emacs style keyboard macros defined using @kbd{C-x(}
viper.texi(,1111) and @kbd{C-x)}.  Emacs keyboard macros have more capabilities.
viper.texi(,1112) @xref{Keyboard Macros,,Keyboard Macros,emacs, The GNU Emacs Manual}, for
viper.texi(,1113) details.@refill
viper.texi(,1114) 
viper.texi(,1115) Keyboard Macros allow an interesting form of Query-Replace:
viper.texi(,1116) @kbd{/pattern} or @kbd{n} to go to the next pattern (the query), followed by a
viper.texi(,1117) Keyboard Macro execution @kbd{@@@@} (the replace).
viper.texi(,1118) 
viper.texi(,1119) Viper also provides Vi-style macros.  @xref{Vi Macros}, for details.
viper.texi(,1120) 
viper.texi(,1121) 
viper.texi(,1122) @node Completion, Improved Search, Macros and Registers, Improvements over Vi
viper.texi(,1123) @section Completion
viper.texi(,1124) 
viper.texi(,1125) @cindex completion
viper.texi(,1126) 
viper.texi(,1127) Completion is done when you type @key{TAB}.  The Emacs completer does not
viper.texi(,1128) grok wildcards in file names.  Once you type a wildcard, the completer will
viper.texi(,1129) no longer work for that file name.  Remember that Emacs interprets a file name
viper.texi(,1130) of the form @kbd{/foo//bar} as @kbd{/bar} and @kbd{/foo/~/bar} as
viper.texi(,1131) @kbd{~/bar}.
viper.texi(,1132) 
viper.texi(,1133) @node Improved Search, Abbreviation Facilities, Completion, Improvements over Vi
viper.texi(,1134) @section Improved Search
viper.texi(,1135) 
viper.texi(,1136) @cindex buffer search
viper.texi(,1137) @cindex word search
viper.texi(,1138) 
viper.texi(,1139) Viper provides buffer search, the ability to search the buffer for a region
viper.texi(,1140) under the cursor.  You have to turn this on in @file{.viper} either by calling
viper.texi(,1141) 
viper.texi(,1142) @example
viper.texi(,1143) (viper-buffer-search-enable)
viper.texi(,1144) @end example
viper.texi(,1145) 
viper.texi(,1146) @noindent
viper.texi(,1147) or by setting @code{viper-buffer-search-char} to, say, @kbd{f3}:
viper.texi(,1148) @example
viper.texi(,1149) (setq viper-buffer-search-char ?g)
viper.texi(,1150) @end example
viper.texi(,1151) 
viper.texi(,1152) @noindent
viper.texi(,1153) If the user calls @code{viper-buffer-search-enable} explicitly (the first
viper.texi(,1154) method), then @code{viper-buffer-search-char} will be set to @kbd{g}.
viper.texi(,1155) Regardless of how this feature is enabled, the key
viper.texi(,1156) @code{viper-buffer-search-char} will take movement commands, like
viper.texi(,1157) @kbd{w,/,e}, to find a region and then search for the contents of that
viper.texi(,1158) region.  This command is very useful for searching for variable names, etc.,
viper.texi(,1159) in a program.  The search can be repeated by @kbd{n} or reversed by @kbd{N}.
viper.texi(,1160) 
viper.texi(,1161) @cindex incremental search
viper.texi(,1162) 
viper.texi(,1163) Emacs provides incremental search.  As you type the string in, the
viper.texi(,1164) cursor will move to the next match.  You can snarf words from the buffer
viper.texi(,1165) as you go along.  Incremental Search is normally bound to @kbd{C-s} and
viper.texi(,1166) @kbd{C-r}.  @xref{Customization}, to find out how to change the bindings
viper.texi(,1167) of @kbd{C-r or C-s}.
viper.texi(,1168) For details, @pxref{Incremental Search,,Incremental
viper.texi(,1169) Search,emacs,The GNU Emacs Manual} @refill
viper.texi(,1170) 
viper.texi(,1171) @cindex query replace
viper.texi(,1172) 
viper.texi(,1173) Viper also provides a query replace function that prompts through the
viper.texi(,1174) Minibuffer.  It is invoked by the @kbd{Q} key in Vi state.
viper.texi(,1175) 
viper.texi(,1176) @cindex mouse search
viper.texi(,1177) 
viper.texi(,1178) On a window display, Viper supports mouse search, i.e., you can search for a
viper.texi(,1179) word by clicking on it.  @xref{Viper Specials}, for details.
viper.texi(,1180) 
viper.texi(,1181) Finally, on a window display, Viper highlights search patterns as it finds
viper.texi(,1182) them.  This is done through what is known as @emph{faces} in Emacs.  The
viper.texi(,1183) variable that controls how search patterns are highlighted is
viper.texi(,1184) @code{viper-search-face}.  If you don't want any highlighting at all, put
viper.texi(,1185) @example
viper.texi(,1186) (copy-face 'default 'viper-search-face)
viper.texi(,1187) @end example
viper.texi(,1188) @vindex @code{viper-search-face}
viper.texi(,1189) @noindent
viper.texi(,1190) in @file{~/.viper}.  If you want to change how patterns are highlighted, you
viper.texi(,1191) will have to change @code{viper-search-face} to your liking.  The easiest
viper.texi(,1192) way to do this is to use Emacs customization widget, which is accessible
viper.texi(,1193) from the menubar.  Viper customization group is located under the
viper.texi(,1194) @emph{Emulations} customization group, which in turn is under the
viper.texi(,1195) @emph{Editing} group (or simply by typing @kbd{:customize}).  All Viper
viper.texi(,1196) faces are grouped together under Viper's 
viper.texi(,1197) @emph{Highlighting} group.
viper.texi(,1198) 
viper.texi(,1199) Try it: it is really simple!
viper.texi(,1200) 
viper.texi(,1201) @node Abbreviation Facilities,Movement and Markers,Improved Search,Improvements over Vi
viper.texi(,1202) @section Abbreviation Facilities
viper.texi(,1203) 
viper.texi(,1204) @cindex abbrevs
viper.texi(,1205) 
viper.texi(,1206) It is possible in Emacs to define abbrevs based on the contents of the
viper.texi(,1207) buffer.
viper.texi(,1208) Sophisticated templates can be defined using the Emacs abbreviation
viper.texi(,1209) facilities.  @xref{Abbrevs,,Abbreviations,emacs,The GNU Emacs Manual}, for
viper.texi(,1210) details.
viper.texi(,1211) 
viper.texi(,1212) @cindex dynamic abbrevs
viper.texi(,1213) 
viper.texi(,1214) Emacs also provides Dynamic Abbreviations.  Given a partial word, Emacs
viper.texi(,1215) will search the buffer to find an extension for this word.  For instance,
viper.texi(,1216) one can type @samp{Abbreviations} by typing @samp{A}, followed by a keystroke
viper.texi(,1217) that completed the @samp{A} to @samp{Abbreviations}.  Repeated typing
viper.texi(,1218) will search further back in the buffer, so that one could get
viper.texi(,1219) @samp{Abbrevs} by repeating the
viper.texi(,1220) keystroke, which appears earlier in the text.  Emacs binds this to
viper.texi(,1221) @kbd{@key{ESC} /}, so you will have to find a key and bind the function
viper.texi(,1222) @code{dabbrev-expand} to that key.
viper.texi(,1223) Facilities like this make Vi's @kbd{:ab} command obsolete.
viper.texi(,1224) 
viper.texi(,1225) @node Movement and Markers, New Commands, Abbreviation Facilities, Improvements over Vi
viper.texi(,1226) @section Movement and Markers
viper.texi(,1227) 
viper.texi(,1228) @cindex Ex style motion
viper.texi(,1229) @cindex line editor motion
viper.texi(,1230) 
viper.texi(,1231) Viper can be set free from the line--limited movements in Vi, such as @kbd{l}
viper.texi(,1232) refusing to move beyond the line, @key{ESC} moving one character back,
viper.texi(,1233) etc.  These derive from Ex, which is a line editor.  If your @file{.viper}
viper.texi(,1234) contains
viper.texi(,1235) 
viper.texi(,1236) @example
viper.texi(,1237) @code{(setq viper-ex-style-motion nil)}
viper.texi(,1238) @end example
viper.texi(,1239) 
viper.texi(,1240) @noindent
viper.texi(,1241) the motion will be a true screen editor motion.  One thing you must then
viper.texi(,1242) watch out for is that it is possible to be on the end-of-line character.
viper.texi(,1243) The keys @kbd{x} and @kbd{%} will still work correctly, i.e., as if they
viper.texi(,1244) were on the last character.
viper.texi(,1245) 
viper.texi(,1246) @vindex @code{viper-syntax-preference}
viper.texi(,1247) @cindex syntax table
viper.texi(,1248) 
viper.texi(,1249) The word-movement commands @kbd{w}, @kbd{e}, etc., and the associated
viper.texi(,1250) deletion/yanking commands, @kbd{dw}, @kbd{yw}, etc., can be made to
viper.texi(,1251) understand Emacs syntax tables.  If the variable
viper.texi(,1252) @code{viper-syntax-preference} is set to @code{strict-vi} then
viper.texi(,1253) the meaning of @emph{word} is the same as in
viper.texi(,1254) Vi.  However, if the value is @code{reformed-vi} (the default) then the
viper.texi(,1255) alphanumeric symbols will be those specified by the current Emacs syntax
viper.texi(,1256) table (which may be different for different major modes) plus the
viper.texi(,1257) underscore symbol @kbd{_}, minus some non-word symbols, like '.;,|, etc.
viper.texi(,1258) Both @code{strict-vi} and @code{reformed-vi} work close to Vi in
viper.texi(,1259) traditional cases, but @code{reformed-vi} does a better job when editing
viper.texi(,1260) text in non-Latin alphabets.
viper.texi(,1261) 
viper.texi(,1262) The user can also specify the value @code{emacs}, which would
viper.texi(,1263) make Viper use exactly the Emacs notion of word.  In particular, the
viper.texi(,1264) underscore may not be part of a word.  Finally, if
viper.texi(,1265) @code{viper-syntax-preference} is set to @code{extended}, Viper words would
viper.texi(,1266) consist of characters that are classified as alphanumeric @emph{or} as
viper.texi(,1267) parts of symbols.  This is convenient for writing programs and in many other
viper.texi(,1268) situations.
viper.texi(,1269) 
viper.texi(,1270) @code{viper-syntax-preference} is a local variable, so it can have different
viper.texi(,1271) values for different major modes.  For instance, in programming modes it can
viper.texi(,1272) have the value @code{extended}.  In text modes where words contain special
viper.texi(,1273) characters, such as European (non-English) letters, Cyrillic letters, etc.,
viper.texi(,1274) the value can be @code{reformed-vi} or @code{emacs}.
viper.texi(,1275) 
viper.texi(,1276) Changes to @code{viper-syntax-preference} should be done in the hooks to
viper.texi(,1277) various major modes by executing @code{viper-set-syntax-preference} as in
viper.texi(,1278) the following example:
viper.texi(,1279) 
viper.texi(,1280) @example
viper.texi(,1281) (viper-set-syntax-preference nil "emacs")
viper.texi(,1282) @end example
viper.texi(,1283) 
viper.texi(,1284) @findex @code{viper-set-syntax-preference}
viper.texi(,1285) 
viper.texi(,1286) The above discussion of the meaning of Viper's words concerns only Viper's
viper.texi(,1287) movement commands.  In regular expressions, words remain the same as in
viper.texi(,1288) Emacs.  That is, the expressions @code{\w}, @code{\>}, @code{\<}, etc., use
viper.texi(,1289) Emacs' idea of what is a word, and they don't look into the value of
viper.texi(,1290) variable @code{viper-syntax-preference}.  This is because Viper doesn't change
viper.texi(,1291) syntax tables in fear of upsetting the various major modes that set these
viper.texi(,1292) tables.
viper.texi(,1293) 
viper.texi(,1294) @cindex textmarkers
viper.texi(,1295) 
viper.texi(,1296) Textmarkers in Viper remember the file and the position, so that you can
viper.texi(,1297) switch files by simply doing @kbd{'a}.  If you set up a regimen for using
viper.texi(,1298) Textmarkers, this is very useful.  Contents of textmarkers can be viewed
viper.texi(,1299) by @kbd{[marker}.  (Contents of registers can be viewed by @kbd{]register}).
viper.texi(,1300) 
viper.texi(,1301) @node New Commands, Useful Packages, Movement and Markers, Improvements over Vi
viper.texi(,1302) @section New Commands
viper.texi(,1303) 
viper.texi(,1304) These commands have no Vi analogs.
viper.texi(,1305) 
viper.texi(,1306) @table @kbd
viper.texi(,1307) @item C-x, C-c
viper.texi(,1308) @kindex @kbd{C-x}
viper.texi(,1309) @kindex @kbd{C-c}
viper.texi(,1310) These two keys invoke many important Emacs functions.  For example, if you
viper.texi(,1311) hit @kbd{C-x} followed by @kbd{2}, then the current window will be split
viper.texi(,1312) into 2.  Except for novice users, @kbd{C-c} is also set to execute an Emacs
viper.texi(,1313) command from the current major mode.  @key{ESC} will do the same, if you
viper.texi(,1314) configure @key{ESC} as Meta by setting @code{viper-no-multiple-ESC} to nil
viper.texi(,1315) in @file{.viper}.  @xref{Customization}.  @kbd{C-\} in Insert, Replace, or Vi
viper.texi(,1316) states will make Emacs think @kbd{Meta} has been hit.@refill
viper.texi(,1317) @item \
viper.texi(,1318) @kindex @kbd{\}
viper.texi(,1319) Escape to Emacs to execute a single Emacs command.  For instance,
viper.texi(,1320) @kbd{\ @key{ESC}} will act like a Meta key.
viper.texi(,1321) @item Q
viper.texi(,1322) @kindex @kbd{Q}
viper.texi(,1323) @cindex query replace
viper.texi(,1324) @kbd{Q} is for query replace.  By default,
viper.texi(,1325) each string to be replaced is treated as a regular expression.  You can use
viper.texi(,1326) @code{(setq viper-re-query-replace nil)} in your @file{.emacs} file to
viper.texi(,1327) turn this off.  (For normal searches, @kbd{:se nomagic} will work.  Note
viper.texi(,1328) that @kbd{:se nomagic} turns Regexps off completely, unlike Vi).
viper.texi(,1329) @item v
viper.texi(,1330) @itemx V
viper.texi(,1331) @itemx C-v
viper.texi(,1332) @kindex @kbd{v}
viper.texi(,1333) @kindex @kbd{V}
viper.texi(,1334) @kindex @kbd{C-v}
viper.texi(,1335) These keys are used to visit files.  @kbd{v} will switch to a buffer
viper.texi(,1336) visiting file whose name can be entered in the Minibuffer.  @kbd{V} is
viper.texi(,1337) similar, but will use a window different from the current window.
viper.texi(,1338) @kbd{C-v} is like @kbd{V}, except that a new frame (X window) will be used
viper.texi(,1339) instead of a new Emacs window.
viper.texi(,1340) @item #
viper.texi(,1341) @kindex @kbd{#}
viper.texi(,1342) If followed by a certain character @var{ch}, it becomes an operator whose
viper.texi(,1343) argument is the region determined by the motion command that follows
viper.texi(,1344) (indicated as <move>).
viper.texi(,1345) Currently, @var{ch} can be one of @kbd{c}, @kbd{C}, @kbd{g}, @kbd{q}, and
viper.texi(,1346) @kbd{s}.  For instance, @kbd{#qr} will prompt you for a string and then
viper.texi(,1347) prepend this string to each line in the buffer.@refill
viper.texi(,1348) @item # c
viper.texi(,1349) @kindex @kbd{#c<move>}
viper.texi(,1350) @cindex changing case
viper.texi(,1351) Change upper-case characters in the region to lower-case
viper.texi(,1352) (@code{downcase-region}).
viper.texi(,1353) Emacs command @kbd{M-l} does the same for words.
viper.texi(,1354) @item # C
viper.texi(,1355) @kindex @kbd{#C<move>}
viper.texi(,1356) Change lower-case characters in the region to upper-case.  For instance,
viper.texi(,1357) @kbd{# C 3 w} will capitalize 3 words from the current point
viper.texi(,1358) (@code{upcase-region}).
viper.texi(,1359) Emacs command @kbd{M-u} does the same for words.
viper.texi(,1360) @item # g
viper.texi(,1361) @kindex @kbd{#g<move>}
viper.texi(,1362) Execute last keyboard macro for each line in the region
viper.texi(,1363) (@code{viper-global-execute}).@refill
viper.texi(,1364) @item # q
viper.texi(,1365) @kindex @kbd{#q<move>}
viper.texi(,1366) Insert specified string at the beginning of each line in the region
viper.texi(,1367) (@code{viper-quote-region}).  The default string is composed of the comment
viper.texi(,1368) character(s) appropriate for the current major mode.
viper.texi(,1369) @item # s
viper.texi(,1370) @kindex @kbd{#s<move>}
viper.texi(,1371) Check spelling of words in the region (@code{spell-region}).
viper.texi(,1372) The function used for spelling is determined from the variable
viper.texi(,1373) @code{viper-spell-function}.
viper.texi(,1374) @vindex @code{viper-spell-function}
viper.texi(,1375) @item *
viper.texi(,1376) @kindex @kbd{*}
viper.texi(,1377) Call last keyboard macro.
viper.texi(,1378) @item m .
viper.texi(,1379) Set mark at point and push old mark off the ring
viper.texi(,1380) @item m<
viper.texi(,1381) @item m>
viper.texi(,1382) Set mark at beginning and end of buffer, respectively.
viper.texi(,1383) @item m,
viper.texi(,1384) Jump to mark and pop mark off the ring.  @xref{Mark,,Mark,emacs,The GNU
viper.texi(,1385) Emacs Manual}, for more info.
viper.texi(,1386) @item ] register
viper.texi(,1387) @kindex @kbd{]<a-z>}
viper.texi(,1388) View contents of register
viper.texi(,1389) @item [ textmarker
viper.texi(,1390) @kindex @kbd{[<a-z>}
viper.texi(,1391) View filename and position of textmarker
viper.texi(,1392) @item @@#
viper.texi(,1393) @item @@register
viper.texi(,1394) @item @@!
viper.texi(,1395) @kindex @kbd{@@#}
viper.texi(,1396) @kindex @kbd{@@<a-z>}
viper.texi(,1397) @kindex @kbd{@@!}
viper.texi(,1398) @cindex keyboard macros
viper.texi(,1399) @cindex register execution
viper.texi(,1400) 
viper.texi(,1401) Begin/end keyboard macro.  @@register has a different meaning when used after
viper.texi(,1402) a @kbd{@@#}.  @xref{Macros and Registers}, for details
viper.texi(,1403) @item []
viper.texi(,1404) @kindex @kbd{[]}
viper.texi(,1405) Go to end of heading.
viper.texi(,1406) @item g <@emph{movement command}>
viper.texi(,1407) Search buffer for text delimited by movement command.  The canonical
viper.texi(,1408) example is @kbd{gw} to search for the word under the cursor.
viper.texi(,1409) @xref{Improved Search}, for details.@refill
viper.texi(,1410) @item C-g and C-]
viper.texi(,1411) @kindex @kbd{C-g}
viper.texi(,1412) @kindex @kbd{C-]}
viper.texi(,1413) Quit and Abort Recursive edit.  These may be necessary on occasion.
viper.texi(,1414) @xref{Vi State}, for a reason.
viper.texi(,1415) @item C-c C-g
viper.texi(,1416) @kindex @kbd{C-c C-g}
viper.texi(,1417) Hitting @kbd{C-c} followed by @kbd{C-g} will display the information on the
viper.texi(,1418) current buffer.  This is the same as hitting @kbd{C-g} in Vi, but, as
viper.texi(,1419) explained above, @kbd{C-g} is needed for other purposes in Emacs.
viper.texi(,1420) @item C-c /
viper.texi(,1421) @kindex @kbd{C-c /}
viper.texi(,1422) Without a prefix argument, this command toggles
viper.texi(,1423) case-sensitive/case-insensitive search modes and plain vanilla/regular
viper.texi(,1424) expression search.  With the prefix argument 1, i.e.,
viper.texi(,1425) @kbd{1 C-c /}, this toggles case-sensitivity; with the prefix argument 2,
viper.texi(,1426) toggles plain vanilla search and search using
viper.texi(,1427) regular expressions.  @xref{Viper Specials}, for alternative ways to invoke
viper.texi(,1428) this function.
viper.texi(,1429) @cindex vanilla search
viper.texi(,1430) @cindex case-sensitive search
viper.texi(,1431) @cindex case-insensitive search
viper.texi(,1432) 
viper.texi(,1433) @item M-p and M-n
viper.texi(,1434) @kindex @kbd{M-p}
viper.texi(,1435) @kindex @kbd{M-n}
viper.texi(,1436) In the Minibuffer, these commands navigate through the minibuffer
viper.texi(,1437) histories, such as the history of search strings, Ex commands, etc.
viper.texi(,1438) 
viper.texi(,1439) @item C-c M-p and C-c M-n
viper.texi(,1440) @kindex @kbd{C-c M-p}
viper.texi(,1441) @kindex @kbd{C-c M-n}
viper.texi(,1442) @cindex Insertion history
viper.texi(,1443) @cindex Insertion ring
viper.texi(,1444) @cindex Command history
viper.texi(,1445) @cindex Command ring
viper.texi(,1446) 
viper.texi(,1447) In Insert or Replace state, these commands let  the user
viper.texi(,1448) peruse the history of insertion strings used in previous insert or replace
viper.texi(,1449) commands.  Try to hit @kbd{C-c M-p} or @kbd{C-c M-n} repeatedly and see what
viper.texi(,1450) happens.  @xref{Viper Specials}, for more.
viper.texi(,1451) 
viper.texi(,1452) In Vi state, these commands let the user peruse the history of Vi-style
viper.texi(,1453) destructive commands, such as @kbd{dw}, @kbd{J}, @kbd{a}, etc.
viper.texi(,1454) By repeatedly typing @kbd{C-c M-p} or @kbd{C-c M-n} you will cycle Viper
viper.texi(,1455) through the recent history of Vi commands, displaying the commands one by
viper.texi(,1456) one.  Once
viper.texi(,1457) an appropriate command is found, it can be executed by typing `@kbd{.}'.
viper.texi(,1458) 
viper.texi(,1459) Since typing @kbd{C-c M-p} is tedious, it is more convenient to bind an
viper.texi(,1460) appropriate function to a function key on the keyboard and use that key.
viper.texi(,1461) @xref{Viper Specials}, for details.
viper.texi(,1462) 
viper.texi(,1463) @item Ex commands
viper.texi(,1464) @findex  @kbd{:args}
viper.texi(,1465) @findex  @kbd{:n}
viper.texi(,1466) @findex  @kbd{:pwd}
viper.texi(,1467) @findex  @kbd{:pre}
viper.texi(,1468) The commands @kbd{:args}, @kbd{:next}, @kbd{:pre} behave
viper.texi(,1469) differently.  @kbd{:pwd} exists to get current directory.
viper.texi(,1470) The commands @kbd{:b} and @kbd{:B} switch buffers around.  @xref{File and
viper.texi(,1471) Buffer Handling}, for details.
viper.texi(,1472) There are also the new commands @kbd{:RelatedFile} and
viper.texi(,1473) @kbd{PreviousRelatedFile} (which abbreviate to @kbd{R} and @kbd{P},
viper.texi(,1474) respectively.  @xref{Viper Specials}, for details.
viper.texi(,1475) @findex @kbd{:RelatedFile}
viper.texi(,1476) @findex @kbd{:PreviousRelatedFile}
viper.texi(,1477) @end table
viper.texi(,1478) 
viper.texi(,1479) Apart from the new commands, many old commands have been enhanced.  Most
viper.texi(,1480) notably, Vi style macros are much more powerful in Viper than in Vi.  @xref{Vi
viper.texi(,1481) Macros}, for details.
viper.texi(,1482) 
viper.texi(,1483) @node Useful Packages, ,New Commands, Improvements over Vi
viper.texi(,1484) @section Useful Packages
viper.texi(,1485) 
viper.texi(,1486) Some Emacs packages are mentioned here as an aid to the new Viper user, to
viper.texi(,1487) indicate what Viper is capable of.
viper.texi(,1488) A vast number comes with the standard Emacs distribution, and many more exist
viper.texi(,1489) on the net and on the archives.
viper.texi(,1490) 
viper.texi(,1491) This manual also mentions some Emacs features a new user
viper.texi(,1492) should know about.  The details of these are found in the GNU Emacs
viper.texi(,1493) Manual.
viper.texi(,1494) 
viper.texi(,1495) The features first.  For details, look up the Emacs Manual.
viper.texi(,1496) 
viper.texi(,1497) @table @samp
viper.texi(,1498) @item Make
viper.texi(,1499) @cindex make
viper.texi(,1500) @cindex compiling
viper.texi(,1501) 
viper.texi(,1502) Makes and Compiles can be done from the editor.  Error messages will be
viper.texi(,1503) parsed and you can move to the error lines.
viper.texi(,1504) @item Shell
viper.texi(,1505) @cindex shell
viper.texi(,1506) @cindex interactive shell
viper.texi(,1507) You can talk to Shells from inside the editor.  Your entire shell session
viper.texi(,1508) can be treated as a file.
viper.texi(,1509) @item Mail
viper.texi(,1510) @cindex email
viper.texi(,1511) @cindex mail
viper.texi(,1512) Mail can be read from and sent within the editor.  Several sophisticated
viper.texi(,1513) packages exist.
viper.texi(,1514) @item Language Sensitive Editing
viper.texi(,1515) Editing modes are written for most computer languages in existence.  By
viper.texi(,1516) controlling indentation, they catch punctuation errors.
viper.texi(,1517) @end table
viper.texi(,1518) 
viper.texi(,1519) The packages, below, represents a drop in the sea of special-purpose
viper.texi(,1520) packages that come with standard distribution of Emacs.
viper.texi(,1521) 
viper.texi(,1522) @table @samp
viper.texi(,1523) @item Transparent FTP
viper.texi(,1524) @cindex transparent ftp
viper.texi(,1525) @pindex ange-ftp.el
viper.texi(,1526) @code{ange-ftp.el} can ftp from the editor to files on other machines
viper.texi(,1527) transparent to the user.
viper.texi(,1528) @item RCS Interfaces
viper.texi(,1529) @cindex version maintenance
viper.texi(,1530) @cindex RCS
viper.texi(,1531) @pindex vc.el
viper.texi(,1532) @code{vc.el} for doing RCS commands from inside the editor
viper.texi(,1533) @item Directory Editor
viper.texi(,1534) @cindex dired
viper.texi(,1535) @pindex dired.el
viper.texi(,1536) @code{dired.el} for editing contents of directories and for navigating in
viper.texi(,1537) the file system.
viper.texi(,1538) @item Syntactic Highlighting
viper.texi(,1539) @cindex font-lock
viper.texi(,1540) @pindex font-lock.el
viper.texi(,1541) @code{font-lock.el} for automatic highlighting various parts of a buffer
viper.texi(,1542) using different fonts and colors.
viper.texi(,1543) @item Saving Emacs Configuration
viper.texi(,1544) @cindex desktop
viper.texi(,1545) @pindex desktop.el
viper.texi(,1546) @code{desktop.el} for saving/restoring configuration on Emacs exit/startup.
viper.texi(,1547) @item Spell Checker
viper.texi(,1548) @cindex ispell
viper.texi(,1549) @pindex ispell.el
viper.texi(,1550) @code{ispell.el} for spell checking the buffer, words, regions, etc.
viper.texi(,1551) @item File and Buffer Comparison
viper.texi(,1552) @cindex ediff
viper.texi(,1553) @pindex ediff.el
viper.texi(,1554) @code{ediff.el} for finding differences between files and for applying
viper.texi(,1555) patches.
viper.texi(,1556) @end table
viper.texi(,1557) 
viper.texi(,1558) @noindent
viper.texi(,1559) Emacs Lisp archives exist on
viper.texi(,1560) @samp{archive.cis.ohio-state.edu}
viper.texi(,1561) and @samp{wuarchive.wustl.edu}@refill
viper.texi(,1562) 
viper.texi(,1563) 
viper.texi(,1564) @node Customization,Commands,Improvements over Vi,Top
viper.texi(,1565) @chapter Customization
viper.texi(,1566) 
viper.texi(,1567) @cindex customization
viper.texi(,1568) 
viper.texi(,1569) Customization can be done in 2 ways.
viper.texi(,1570) 
viper.texi(,1571) @itemize @bullet
viper.texi(,1572) @item
viper.texi(,1573) @cindex initialization
viper.texi(,1574) @cindex .viper
viper.texi(,1575) Elisp code in a @file{.viper} file in your home directory.  Viper
viper.texi(,1576) loads @file{.viper} just before it does the binding for mode
viper.texi(,1577) hooks.  This is recommended for experts only.
viper.texi(,1578) @item
viper.texi(,1579) @cindex .emacs
viper.texi(,1580) Elisp code in your @file{.emacs} file before and after the @code{(require
viper.texi(,1581) 'viper)} line.  This method is @emph{not} recommended, unless you know what
viper.texi(,1582) you are doing.  Only two variables, @code{viper-mode} and
viper.texi(,1583) @code{viper-custom-file-name}, are supposed to be customized in @file{.emacs},
viper.texi(,1584) prior to loading Viper (i.e., prior to @code{(require 'viper)} command.@refill
viper.texi(,1585) @item
viper.texi(,1586) @cindex :customize
viper.texi(,1587) By executing the @kbd{:customize} Ex command. This takes you to the Emacs
viper.texi(,1588) customization widget, which lets you change the values of Viper
viper.texi(,1589) customizable variables easily. This method is good for novice and
viper.texi(,1590) experts alike. The customization code in the form of Lisp commands will be
viper.texi(,1591) placed in @file{~/.emacs} or some other customization file depending on the
viper.texi(,1592) version of Emacs that you use. Still, it is recommended to separate
viper.texi(,1593) Viper-related customization produced by the Emacs customization widget
viper.texi(,1594) and keep it in the @file{.viper} file.
viper.texi(,1595) 
viper.texi(,1596) Some advanced customization cannot be accomplished this way, however, and
viper.texi(,1597) has to be done in Emacs Lisp in the @file{.viper} file.  For the common
viper.texi(,1598) cases, examples are provided that you can use directly.
viper.texi(,1599) @end itemize
viper.texi(,1600) 
viper.texi(,1601) 
viper.texi(,1602) @menu
viper.texi(,1603) * Rudimentary Changes::          Simple constant definitions.
viper.texi(,1604) * Key Bindings::                 Enabling Emacs Keys, Rebinding keys, etc.
viper.texi(,1605) * Packages that Change Keymaps:: How to deal with such beasts.
viper.texi(,1606) * Viper Specials::               Special Viper commands.
viper.texi(,1607) * Vi Macros::                    How to do Vi style macros.
viper.texi(,1608) @end menu
viper.texi(,1609) 
viper.texi(,1610) @node Rudimentary Changes,Key Bindings,Customization,Customization
viper.texi(,1611) @section Rudimentary Changes
viper.texi(,1612) 
viper.texi(,1613) @cindex setting variables
viper.texi(,1614) @cindex variables for customization
viper.texi(,1615) @findex @kbd{:set}
viper.texi(,1616) 
viper.texi(,1617) An easy way to customize Viper is to change the values of constants used in
viper.texi(,1618) Viper.  Here is the list of the constants used in Viper and their default
viper.texi(,1619) values.  The corresponding :se command is also indicated.  (The symbols
viper.texi(,1620) @code{t} and @code{nil} represent ``true'' and ``false'' in Lisp).
viper.texi(,1621) 
viper.texi(,1622) Viper supports both the abbreviated Vi variable names and their full
viper.texi(,1623) names.  Variable completion is done on full names only.  @key{TAB} and
viper.texi(,1624) @key{SPC} complete
viper.texi(,1625) variable names.  Typing `=' will complete the name and then will prompt for
viper.texi(,1626) a value, if applicable.  For instance, @kbd{:se au @key{SPC}} will complete the
viper.texi(,1627) command to @kbd{:set autoindent}; @kbd{:se ta @key{SPC}} will complete the command
viper.texi(,1628) and prompt further like this: @kbd{:set tabstop = }.
viper.texi(,1629) However, typing @kbd{:se ts @key{SPC}} will produce a ``No match'' message
viper.texi(,1630) because @kbd{ts} is an abbreviation for @kbd{tabstop} and Viper supports
viper.texi(,1631) completion on full names only.  However, you can still hit @key{RET}
viper.texi(,1632) or @kbd{=}, which will complete the command like this: @kbd{:set ts = } and
viper.texi(,1633) Viper will be waiting for you to type a value for the tabstop variable.
viper.texi(,1634) To get the full list of Vi variables, type @kbd{:se @key{SPC} @key{TAB}}.
viper.texi(,1635) 
viper.texi(,1636) @table @code
viper.texi(,1637) @item viper-auto-indent nil
viper.texi(,1638) @itemx :se ai (:se autoindent)
viper.texi(,1639) @itemx :se ai-g (:se autoindent-global)
viper.texi(,1640) If @code{t}, enable auto indentation.
viper.texi(,1641) by @key{RET}, @kbd{o} or @kbd{O} command.
viper.texi(,1642) 
viper.texi(,1643) @code{viper-auto-indent} is a local variable.  To change the value globally, use
viper.texi(,1644) @code{setq-default}.  It may be useful for certain major modes to have their
viper.texi(,1645) own values of @code{viper-auto-indent}.  This can be achieved by using
viper.texi(,1646) @code{setq} to change the local value of this variable in the hooks to the
viper.texi(,1647) appropriate major modes.
viper.texi(,1648) 
viper.texi(,1649) @kbd{:se ai} changes the value of @code{viper-auto-indent} in the current
viper.texi(,1650) buffer only; @kbd{:se ai-g} does the same globally.
viper.texi(,1651) @item viper-electric-mode t
viper.texi(,1652) If not @code{nil}, auto-indentation becomes electric, which means that
viper.texi(,1653) @key{RET}, @kbd{O}, and @kbd{o} indent cursor according to the current
viper.texi(,1654) major mode.  In the future, this variable may control additional electric
viper.texi(,1655) features.
viper.texi(,1656) 
viper.texi(,1657) This is a local variable: @code{setq} changes the value of this variable
viper.texi(,1658) in the current buffer only.  Use @code{setq-default} to change the value in
viper.texi(,1659) all buffers.
viper.texi(,1660) @item viper-case-fold-search nil
viper.texi(,1661) @itemx :se ic (:se ignorecase)
viper.texi(,1662) If not @code{nil}, search ignores cases.
viper.texi(,1663) This can also be toggled by quickly hitting @kbd{/} twice.
viper.texi(,1664) @item viper-re-search nil
viper.texi(,1665) @itemx :se magic
viper.texi(,1666) If not @code{nil}, search will use regular expressions; if @code{nil} then
viper.texi(,1667) use vanilla search.
viper.texi(,1668) This behavior can also be toggled by quickly hitting @kbd{/} trice.
viper.texi(,1669) @item buffer-read-only
viper.texi(,1670) @itemx :se ro (:se readonly)
viper.texi(,1671) Set current buffer to read only.  To change globally put
viper.texi(,1672) @code{(setq-default buffer-read-only t)} in your @file{.emacs} file.
viper.texi(,1673) @item blink-matching-paren t
viper.texi(,1674) @itemx :se sm (:se showmatch)
viper.texi(,1675) Show matching parens by blinking cursor.
viper.texi(,1676) @item tab-width t (default setting via @code{setq-default})
viper.texi(,1677) @itemx :se ts=value (:se tabstop=value)
viper.texi(,1678) @itemx :se ts-g=value (:se tabstop-global=value)
viper.texi(,1679) @code{tab-width} is a local variable that controls the width of the tab stops.
viper.texi(,1680) To change the value globally, use @code{setq-default}; for local settings,
viper.texi(,1681) use @code{setq}.
viper.texi(,1682) 
viper.texi(,1683) The command @kbd{:se ts}
viper.texi(,1684) sets the tab width in the current
viper.texi(,1685) buffer only; it has no effect on other buffers.
viper.texi(,1686) 
viper.texi(,1687) The command @kbd{:se ts-g} sets tab width globally,
viper.texi(,1688) for all buffers where the tab is not yet set locally,
viper.texi(,1689) including the new buffers.
viper.texi(,1690) 
viper.texi(,1691) Note that typing @key{TAB} normally
viper.texi(,1692) doesn't insert the tab, since this key is usually bound to
viper.texi(,1693) a text-formatting function, @code{indent-for-tab-command} (which facilitates
viper.texi(,1694) programming and document writing).  Instead, the tab is inserted via the
viper.texi(,1695) command @code{viper-insert-tab}, which is bound to @kbd{S-tab} (shift + tab).
viper.texi(,1696) 
viper.texi(,1697) On some non-windowing terminals, Shift doesn't modify the @key{TAB} key, so
viper.texi(,1698) @kbd{S-tab} behaves as if it were @key{TAB}.  In such a case, you will have
viper.texi(,1699) to bind @code{viper-insert-tab} to some other convenient key.
viper.texi(,1700) 
viper.texi(,1701) @item viper-shift-width 8
viper.texi(,1702) @itemx :se sw=value  (:se shiftwidth=value)
viper.texi(,1703) The number of columns shifted by @kbd{>} and @kbd{<} commands.
viper.texi(,1704) @item viper-search-wrap-around t
viper.texi(,1705) @itemx :se ws (:se wrapscan)
viper.texi(,1706) If not @code{nil}, search wraps around the end/beginning of buffer.
viper.texi(,1707) @item viper-search-scroll-threshold 2
viper.texi(,1708) If search lands within this many lines of the window top or bottom, the
viper.texi(,1709) window will be scrolled up or down by about 1/7-th of its size, to reveal
viper.texi(,1710) the context.  If the value is negative---don't scroll.
viper.texi(,1711) @item viper-tags-file-name "TAGS"
viper.texi(,1712) The name of the file used as the tag table.
viper.texi(,1713) @item viper-re-query-replace nil
viper.texi(,1714) If not @code{nil}, use reg-exp replace in query replace.
viper.texi(,1715) @item viper-want-ctl-h-help nil
viper.texi(,1716) If not @code{nil}, @kbd{C-h} is bound to @code{help-command};
viper.texi(,1717) otherwise, @kbd{C-h} is bound as usual in Vi.
viper.texi(,1718) @item viper-vi-style-in-minibuffer t
viper.texi(,1719) If not @code{nil}, Viper provides a high degree of compatibility with Vi
viper.texi(,1720) insert mode when you type text in the Minibuffer; if @code{nil}, typing in
viper.texi(,1721) the Minibuffer feels like plain Emacs.
viper.texi(,1722) @item viper-no-multiple-ESC t
viper.texi(,1723) If you set this to @code{nil}, you can use @key{ESC} as Meta in Vi state.
viper.texi(,1724) Normally, this is not necessary, since graphical displays have separate
viper.texi(,1725) Meta keys (usually on each side of the space bar).  On a dumb terminal, Viper
viper.texi(,1726) sets this variable to @code{twice}, which is almost like @code{nil}, except
viper.texi(,1727) that double @key{ESC} beeps.  This, too, lets @key{ESC} to be used as a Meta.
viper.texi(,1728) @item viper-ESC-keyseq-timeout 200 on tty, 0 on windowing display
viper.texi(,1729) Escape key sequences separated by this much delay (in milliseconds) are
viper.texi(,1730) interpreted as command, ignoring the special meaning of @key{ESC} in
viper.texi(,1731) VI.  The default is suitable for most terminals.  However, if your terminal
viper.texi(,1732) is extremely slow, you might want to increase this slightly.  You will know
viper.texi(,1733) if your terminal is slow if the @key{ESC} key sequences emitted by the
viper.texi(,1734) arrow keys are interpreted as separately typed characters (and thus the
viper.texi(,1735) arrow keys won't work).  Making this value too large will slow you down, so
viper.texi(,1736) exercise restraint.
viper.texi(,1737) @item viper-fast-keyseq-timeout 200
viper.texi(,1738) Key sequences separated by this many milliseconds are treated as Vi-style
viper.texi(,1739) keyboard macros.  If the key sequence is defined as such a macro, it will be
viper.texi(,1740) executed.  Otherwise, it is processed as an ordinary sequence of typed keys.
viper.texi(,1741) 
viper.texi(,1742) Setting this variable too high may slow down your typing.  Setting it too
viper.texi(,1743) low may make it hard to type macros quickly enough.
viper.texi(,1744) @item viper-translate-all-ESC-keysequences t on tty, nil on windowing display
viper.texi(,1745) Normally, Viper lets Emacs translate only those ESC key sequences that are
viper.texi(,1746) defined in the low-level key-translation-map or function-key-map, such as those
viper.texi(,1747) emitted by the arrow and function keys. Other sequences, e.g., @kbd{\\e/}, are
viper.texi(,1748) treated as @kbd{ESC} command followed by a @kbd{/}. This is good for people
viper.texi(,1749) who type fast and tend to hit other characters right after they hit
viper.texi(,1750) ESC. Other people like Emacs to translate @kbd{ESC} sequences all the time. 
viper.texi(,1751) The default is to translate all sequences only when using a dumb terminal.
viper.texi(,1752) This permits you to use @kbd{ESC} as a meta key in insert mode. For instance,
viper.texi(,1753) hitting @kbd{ESC x} fast would have the effect of typing @kbd{M-x}.
viper.texi(,1754) If your dumb terminal is not so dumb and understands the meta key, then you
viper.texi(,1755) probably will be better off setting this variable to nil. Try and see which
viper.texi(,1756) way suits you best.
viper.texi(,1757) @item viper-ex-style-motion t
viper.texi(,1758) Set this to @code{nil}, if you want @kbd{l,h} to cross
viper.texi(,1759) lines, etc.  @xref{Movement and Markers}, for more info.
viper.texi(,1760) @item viper-ex-style-editing t
viper.texi(,1761) Set this to @code{nil}, if you want
viper.texi(,1762) @kbd{C-h} and @key{DEL} to not stop
viper.texi(,1763) at the beginning of a line in Insert state, @key{X} and @key{x} to delete
viper.texi(,1764) characters across lines in Vi command state, etc.
viper.texi(,1765) @item viper-ESC-moves-cursor-back t
viper.texi(,1766) It t, cursor moves back 1 character when switching from insert state to vi
viper.texi(,1767) state.  If nil, the cursor stays where it was before the switch.
viper.texi(,1768) @item viper-always t
viper.texi(,1769) @code{t} means: leave it to Viper to decide when a buffer must be brought
viper.texi(,1770) up in Vi state,
viper.texi(,1771) Insert state, or Emacs state.  This heuristics works well in virtually all
viper.texi(,1772) cases.  @code{nil} means you either has to invoke @code{viper-mode} manually
viper.texi(,1773) for each buffer (or you can add @code{viper-mode} to the appropriate major mode
viper.texi(,1774) hooks using @code{viper-load-hook}).
viper.texi(,1775) 
viper.texi(,1776) This option must be set in the file @file{~/.viper}.
viper.texi(,1777) @item viper-custom-file-name "~/.viper"
viper.texi(,1778) File used for Viper-specific customization.
viper.texi(,1779) Change this setting, if you want.  Must be set in @file{.emacs} (not @file{.viper}!)
viper.texi(,1780) before Viper is loaded.  Note that you
viper.texi(,1781) have to set it as a string inside double quotes.
viper.texi(,1782) @item viper-spell-function 'ispell-region
viper.texi(,1783) Function used by the command @kbd{#c<move>} to spell.
viper.texi(,1784) @item viper-glob-function
viper.texi(,1785) The value of this variable is the function symbol used to expand wildcard
viper.texi(,1786) symbols. This is platform-dependent. The default tries to set this variable
viper.texi(,1787) to work with most shells, MS Windows, OS/2, etc. However, if it
viper.texi(,1788) doesn't work the way you expect, you should write your own.
viper.texi(,1789) Use @code{viper-glob-unix-files} and @code{viper-glob-mswindows-files} in
viper.texi(,1790) @file{viper-util.el} as examples.
viper.texi(,1791) 
viper.texi(,1792) This feature is used to expand wildcards in the Ex command @kbd{:e}.
viper.texi(,1793) Note that Viper doesn't support wildcards in the @kbd{:r} and @kbd{:w}
viper.texi(,1794) commands, because file completion is a better mechanism.
viper.texi(,1795) @findex @code{viper-glob-function}
viper.texi(,1796) 
viper.texi(,1797) @item ex-cycle-other-window t
viper.texi(,1798) If not @code{nil}, @kbd{:n} and @kbd{:b} will cycle through files in another
viper.texi(,1799) window, if one exists.
viper.texi(,1800) @item ex-cycle-through-non-files nil
viper.texi(,1801) @kbd{:n} does not normally cycle through buffers.  Set this to get
viper.texi(,1802) buffers also.
viper.texi(,1803) @item viper-want-emacs-keys-in-insert
viper.texi(,1804) This is set to @code{nil} for user levels 1 and 2 and to @code{t} for user
viper.texi(,1805) levels 3 and 4.  Users who specify level 5 are allowed to set this variable
viper.texi(,1806) as they please (the default for this level is @code{t}).  If set to
viper.texi(,1807) @code{nil}, complete Vi compatibility is provided in Insert state.  This is
viper.texi(,1808) really not recommended, as this precludes you from using language-specific
viper.texi(,1809) features provided by the major modes.
viper.texi(,1810) @item viper-want-emacs-keys-in-vi
viper.texi(,1811) This is set to @code{nil} for user
viper.texi(,1812) level 1 and to @code{t} for user levels 2--4.
viper.texi(,1813) At level 5, users are allowed to set this variable as they please (the
viper.texi(,1814) default for this level is @code{t}).
viper.texi(,1815) If set to @code{nil}, complete Vi compatibility is provided
viper.texi(,1816) in Vi command state.  Setting this to @code{nil} is really a bad idea,
viper.texi(,1817) unless you are a novice, as this precludes the use
viper.texi(,1818) of language-specific features provided by the major modes.
viper.texi(,1819) @item viper-keep-point-on-repeat t
viper.texi(,1820) If not @code{nil}, point is not moved when the user repeats the previous
viper.texi(,1821) command by typing `.'  This is very useful for doing repeated changes with
viper.texi(,1822) the @kbd{.} key.
viper.texi(,1823) @item viper-repeat-from-history-key 'f12
viper.texi(,1824) Prefix key used to invoke the macros @kbd{f12 1} and @kbd{f12 2} that repeat
viper.texi(,1825) the second-last and the third-last destructive command.
viper.texi(,1826) Both these macros are bound (as Viper macros) to
viper.texi(,1827) @code{viper-repeat-from-history},
viper.texi(,1828) which checks the second key by which it is invoked to see which of the
viper.texi(,1829) previous commands to invoke.  Viper binds @kbd{f12 1} and @kbd{f12 2} only,
viper.texi(,1830) but the user can bind more in @file{~/.viper}.  @xref{Vi Macros}, for how to do
viper.texi(,1831) this.
viper.texi(,1832) @item viper-keep-point-on-undo nil
viper.texi(,1833) If not @code{nil}, Viper tries to not move point when undoing commands.
viper.texi(,1834) Instead, it will briefly move the cursor to the place where change has
viper.texi(,1835) taken place.  However, if the undone piece of text is not seen in window,
viper.texi(,1836) then point will be moved to the place where the change took place.
viper.texi(,1837) Set it to @code{t} and see if you like it better.
viper.texi(,1838) @item viper-delete-backwards-in-replace nil
viper.texi(,1839) If not @code{nil}, @key{DEL} key will delete characters while moving the cursor
viper.texi(,1840) backwards.  If @code{nil}, the cursor will move backwards without deleting
viper.texi(,1841) anything.
viper.texi(,1842) @item viper-replace-overlay-face 'viper-replace-overlay-face
viper.texi(,1843) On a graphical display, Viper highlights replacement regions instead of
viper.texi(,1844) putting a @samp{$} at the end.  This variable controls the so called
viper.texi(,1845) @dfn{face} used to highlight the region.
viper.texi(,1846) 
viper.texi(,1847) By default, @code{viper-replace-overlay-face} underlines the replacement on
viper.texi(,1848) monochrome displays and also lays a stipple over them.  On color displays,
viper.texi(,1849) replacement regions are highlighted with color.
viper.texi(,1850) 
viper.texi(,1851) If you know something about Emacs faces and don't like how Viper highlights
viper.texi(,1852) replacement regions, you can change @code{viper-replace-overlay-face} by
viper.texi(,1853) specifying a new face.  (Emacs faces are described in the Emacs Lisp
viper.texi(,1854) reference.)  On a color display, the following customization method is
viper.texi(,1855) usually most effective:
viper.texi(,1856) @example
viper.texi(,1857) (set-face-foreground viper-replace-overlay-face "DarkSlateBlue")
viper.texi(,1858) (set-face-background viper-replace-overlay-face "yellow")
viper.texi(,1859) @end example
viper.texi(,1860) For a complete list of colors available to you, evaluate the expression
viper.texi(,1861) @code{(x-defined-colors)}.  (Type it in the buffer @code{*scratch*} and then
viper.texi(,1862) hit the @kbd{C-j} key.
viper.texi(,1863) 
viper.texi(,1864) @item viper-replace-overlay-cursor-color  "Red"
viper.texi(,1865) @vindex @code{viper-replace-overlay-cursor-color}
viper.texi(,1866) Cursor color when it is inside the replacement region.
viper.texi(,1867) This has effect only on color displays and only when Emacs runs as an X
viper.texi(,1868) application.
viper.texi(,1869) @item viper-insert-state-cursor-color nil
viper.texi(,1870) @vindex @code{viper-insert-state-cursor-color}
viper.texi(,1871) If set to a valid color, this will be the cursor color when Viper is in
viper.texi(,1872) insert state.
viper.texi(,1873) @item viper-replace-region-end-delimiter "$"
viper.texi(,1874) A string used to mark the end of replacement regions.  It is used only on
viper.texi(,1875) TTYs or if @code{viper-use-replace-region-delimiters} is non-nil.
viper.texi(,1876) @item viper-replace-region-start-delimiter  ""
viper.texi(,1877) A string used to mark the beginning of replacement regions.  It is used
viper.texi(,1878) only on TTYs or if @code{viper-use-replace-region-delimiters} is non-nil.
viper.texi(,1879) @item viper-use-replace-region-delimiters
viper.texi(,1880) If non-nil, Viper will always use @code{viper-replace-region-end-delimiter} and
viper.texi(,1881) @code{viper-replace-region-start-delimiter} to delimit replacement regions,
viper.texi(,1882) even on color displays (where this is unnecessary).  By default, this
viper.texi(,1883) variable is non-nil only on TTYs or monochrome displays.
viper.texi(,1884) @item viper-allow-multiline-replace-regions t
viper.texi(,1885) If non-nil, multi-line text replacement regions, such as those produced by
viper.texi(,1886) commands @kbd{c55w}, @kbd{3C}, etc., will stay around until the user exits
viper.texi(,1887) the replacement mode.  In this variable is set to @code{nil}, Viper will
viper.texi(,1888) emulate the standard Vi behavior, which supports only intra-line
viper.texi(,1889) replacement regions (and multi-line replacement regions are deleted).
viper.texi(,1890) @item viper-toggle-key "\C-z"
viper.texi(,1891) Specifies the key used to switch from Emacs to Vi and back.
viper.texi(,1892) Must be set in @file{.viper}.  This variable can't be
viper.texi(,1893) changed interactively after Viper is loaded.
viper.texi(,1894) 
viper.texi(,1895) In Insert state, this key acts as a temporary escape to Vi state, i.e., it
viper.texi(,1896) will set Viper up so that the very next command will be executed as if it
viper.texi(,1897) were typed in Vi state.
viper.texi(,1898) @item viper-ESC-key "\e"
viper.texi(,1899) Specifies the key used to escape from Insert/Replace states to Vi.
viper.texi(,1900) Must be set in @file{.viper}.  This variable cannot be
viper.texi(,1901) changed interactively after Viper is loaded.
viper.texi(,1902) @item viper-buffer-search-char nil
viper.texi(,1903) Key used for buffer search.  @xref{Viper Specials}, for details.
viper.texi(,1904) @item viper-surrounding-word-function 'viper-surrounding-word
viper.texi(,1905) The value of this variable is a function name that is used to determine
viper.texi(,1906) what constitutes a word clicked upon by the mouse.  This is used by mouse
viper.texi(,1907) search and insert.
viper.texi(,1908) @item viper-search-face 'viper-search-face
viper.texi(,1909) Variable that controls how search patterns are highlighted when they are
viper.texi(,1910) found.
viper.texi(,1911) @item viper-vi-state-hook nil
viper.texi(,1912) List of parameterless functions to be run just after entering the Vi
viper.texi(,1913) command state.
viper.texi(,1914) @item viper-insert-state-hook nil
viper.texi(,1915) Same for Insert state.  This hook is also run after entering Replace state.
viper.texi(,1916) @item viper-replace-state-hook  nil
viper.texi(,1917) List of (parameterless) functions called just after entering Replace state
viper.texi(,1918) (and after all @code{viper-insert-state-hook}).
viper.texi(,1919) @item viper-emacs-state-hook nil
viper.texi(,1920) List of (parameterless) functions called just after switching from Vi state
viper.texi(,1921) to Emacs state.
viper.texi(,1922) @item viper-load-hook nil
viper.texi(,1923) List of (parameterless) functions called just after loading Viper.  This is
viper.texi(,1924) the last chance to do customization before Viper is up and running.
viper.texi(,1925) @end table
viper.texi(,1926) @noindent
viper.texi(,1927) You can reset some of these constants in Viper with the Ex command @kbd{:set}
viper.texi(,1928) (when so indicated in the table).  Or you
viper.texi(,1929) can include a line like this in your @file{.viper} file:
viper.texi(,1930) @example
viper.texi(,1931) (setq viper-case-fold-search t)
viper.texi(,1932) @end example
viper.texi(,1933) @vindex @code{viper-auto-indent}
viper.texi(,1934) @vindex @code{viper-electric-mode}
viper.texi(,1935) @vindex @code{viper-case-fold-search}
viper.texi(,1936) @vindex @code{viper-re-search}
viper.texi(,1937) @vindex @code{viper-shift-width}
viper.texi(,1938) @vindex @code{buffer-read-only}
viper.texi(,1939) @vindex @code{viper-search-wrap-around}
viper.texi(,1940) @vindex @code{viper-search-scroll-threshold}
viper.texi(,1941) @vindex @code{viper-search-face}
viper.texi(,1942) @vindex @code{viper-tags-file-name}
viper.texi(,1943) @vindex @code{viper-re-query-replace}
viper.texi(,1944) @vindex @code{viper-want-ctl-h-help}
viper.texi(,1945) @vindex @code{viper-vi-style-in-minibuffer}
viper.texi(,1946) @vindex @code{viper-no-multiple-ESC}
viper.texi(,1947) @vindex @code{viper-always}
viper.texi(,1948) @vindex @code{viper-ESC-keyseq-timeout}
viper.texi(,1949) @vindex @code{viper-fast-keyseq-timeout}
viper.texi(,1950) @vindex @code{viper-ex-style-motion}
viper.texi(,1951) @vindex @code{viper-ex-style-editing}
viper.texi(,1952) @vindex @code{viper-ESC-moves-cursor-back}
viper.texi(,1953) @vindex @code{viper-custom-file-name}
viper.texi(,1954) @vindex @code{viper-spell-function}
viper.texi(,1955) @vindex @code{ex-cycle-other-window}
viper.texi(,1956) @vindex @code{ex-cycle-through-non-files}
viper.texi(,1957) @vindex @code{viper-want-emacs-keys-in-insert}
viper.texi(,1958) @vindex @code{viper-want-emacs-keys-in-vi}
viper.texi(,1959) @vindex @code{viper-keep-point-on-repeat}
viper.texi(,1960) @vindex @code{viper-keep-point-on-undo}
viper.texi(,1961) @vindex @code{viper-delete-backwards-in-replace}
viper.texi(,1962) @vindex @code{viper-replace-overlay-face}
viper.texi(,1963) @vindex @code{viper-replace-region-end-symbol}
viper.texi(,1964) @vindex @code{viper-replace-region-start-symbol}
viper.texi(,1965) @vindex @code{viper-allow-multiline-replace-regions}
viper.texi(,1966) @vindex @code{viper-toggle-key}
viper.texi(,1967) @vindex @code{viper-ESC-key}
viper.texi(,1968) @vindex @code{viper-buffer-search-char}
viper.texi(,1969) @vindex @code{viper-surrounding-word-function}
viper.texi(,1970) @vindex @code{viper-vi-state-hook}
viper.texi(,1971) @vindex @code{viper-insert-state-hook}
viper.texi(,1972) @vindex @code{viper-replace-state-hook}
viper.texi(,1973) @vindex @code{viper-emacs-state-hook}
viper.texi(,1974) 
viper.texi(,1975) @node Key Bindings, Packages that Change Keymaps, Rudimentary Changes,Customization
viper.texi(,1976) @section Key Bindings
viper.texi(,1977) 
viper.texi(,1978) @cindex key bindings
viper.texi(,1979) @cindex keymaps
viper.texi(,1980) 
viper.texi(,1981) Viper lets you define hot keys, i.e., you can associate keyboard keys
viper.texi(,1982) such as F1, Help, PgDn, etc., with Emacs Lisp functions (that may already
viper.texi(,1983) exist or that you will write).  Each key has a "preferred form" in
viper.texi(,1984) Emacs.  For instance, the Up key's preferred form is [up], the Help key's
viper.texi(,1985) preferred form is [help], and the Undo key has the preferred form [f14].
viper.texi(,1986) You can find out the preferred form of a key by typing @kbd{M-x
viper.texi(,1987) describe-key-briefly} and then typing the key you want to know about.
viper.texi(,1988) 
viper.texi(,1989) Under the X Window System, every keyboard key emits its preferred form,
viper.texi(,1990) so you can just type
viper.texi(,1991) 
viper.texi(,1992) @lisp
viper.texi(,1993) (global-set-key [f11] 'calendar)                        ; L1, Stop
viper.texi(,1994) (global-set-key [f14] 'undo)                            ; L4, Undo
viper.texi(,1995) @end lisp
viper.texi(,1996) 
viper.texi(,1997) @noindent
viper.texi(,1998) to bind L1 (a key that exists on some SUN workstations) so it will invoke
viper.texi(,1999) the Emacs Calendar and to bind L4 so it will undo changes.
viper.texi(,2000) However, on a dumb terminal or in an Xterm window, even the standard arrow
viper.texi(,2001) keys may
viper.texi(,2002) not emit the right signals for Emacs to understand.  To let Emacs know about
viper.texi(,2003) those keys, you will have to find out which key sequences they emit
viper.texi(,2004) by typing @kbd{C-q} and then the key (you should switch to Emacs state
viper.texi(,2005) first).  Then you can bind those sequences to their preferred forms using
viper.texi(,2006) @code{function-key-map} as follows:
viper.texi(,2007) 
viper.texi(,2008) @lisp
viper.texi(,2009) (cond ((string= (getenv "TERM") "xterm")
viper.texi(,2010) (define-key function-key-map "\e[192z" [f11])    ; L1
viper.texi(,2011) (define-key function-key-map "\e[195z" [f14])    ; L4, Undo
viper.texi(,2012) @end lisp
viper.texi(,2013) 
viper.texi(,2014) The above illustrates how to do this for Xterm.  On VT100, you would have to
viper.texi(,2015) replace "xterm" with "vt100" and also change the key sequences (the same
viper.texi(,2016) key may emit different sequences on different types of terminals).
viper.texi(,2017) 
viper.texi(,2018) The above keys are global, so they are overwritten by the local maps
viper.texi(,2019) defined by the major modes and by Viper itself.  Therefore, if you wish to
viper.texi(,2020) change a binding set by a major mode or by Viper, read this.
viper.texi(,2021) 
viper.texi(,2022) Viper users who wish to specify their own key bindings should be concerned
viper.texi(,2023) only with the following three keymaps:
viper.texi(,2024) @code{viper-vi-global-user-map} for Vi state commands,
viper.texi(,2025) @code{viper-insert-global-user-map} for Insert state commands,
viper.texi(,2026) and @code{viper-emacs-global-user-map} for Emacs state commands (note:
viper.texi(,2027) customized bindings for Emacs state made to @code{viper-emacs-global-user-map}
viper.texi(,2028) are @emph{not} inherited by Insert state).
viper.texi(,2029) 
viper.texi(,2030) For more information on Viper keymaps, see the header of the file
viper.texi(,2031) @file{viper.el}.
viper.texi(,2032) If you wish to change a Viper binding, you can use the
viper.texi(,2033) @code{define-key} command, to modify @code{viper-vi-global-user-map},
viper.texi(,2034) @code{viper-insert-global-user-map}, and @code{viper-emacs-global-user-map}, as
viper.texi(,2035) explained below.  Each of these key maps affects the corresponding Viper state.
viper.texi(,2036) The keymap @code{viper-insert-global-user-map} also affects Viper's Replace
viper.texi(,2037) state. 
viper.texi(,2038) 
viper.texi(,2039) @noindent
viper.texi(,2040) If you want to
viper.texi(,2041) bind a key, say @kbd{C-v}, to the function that scrolls
viper.texi(,2042) page down and to make @kbd{0} display information on the current buffer,
viper.texi(,2043) putting this in @file{.viper} will do the trick in Vi state:
viper.texi(,2044) @example
viper.texi(,2045) (define-key viper-vi-global-user-map "\C-v" 'scroll-down)
viper.texi(,2046) @end example
viper.texi(,2047) @noindent
viper.texi(,2048) To set a key globally,
viper.texi(,2049) @example
viper.texi(,2050) (define-key viper-emacs-global-user-map "\C-c m" 'smail)
viper.texi(,2051) (define-key viper-vi-global-user-map "0" 'viper-info-on-file)
viper.texi(,2052) @end example
viper.texi(,2053) @noindent
viper.texi(,2054) Note, however, that this binding may be overwritten by other keymaps, since
viper.texi(,2055) the global keymap has the lowest priority.
viper.texi(,2056) To make sure that nothing will override a binding in Emacs state, you
viper.texi(,2057) can write this:
viper.texi(,2058) @example
viper.texi(,2059) (define-key viper-emacs-global-user-map "\C-c m" 'smail)
viper.texi(,2060) @end example
viper.texi(,2061) @noindent
viper.texi(,2062) To customize the binding for @kbd{C-h} in Insert state:
viper.texi(,2063) @example
viper.texi(,2064) (define-key viper-insert-global-user-map "\C-h" 'my-del-backwards-function)
viper.texi(,2065) @end example
viper.texi(,2066) @noindent
viper.texi(,2067) 
viper.texi(,2068) Each Emacs command key calls some lisp function.  If you have enabled the
viper.texi(,2069) Help, (@pxref{Rudimentary Changes}) @kbd{C-h k} will show you the function
viper.texi(,2070) for each specific key; @kbd{C-h b} will show all bindings, and @kbd{C-h m}
viper.texi(,2071) will provide information on the major mode in effect.  If Help is not
viper.texi(,2072) enabled, you can still get help in Vi state by prefixing the above commands
viper.texi(,2073) with @kbd{\}, e.g., @kbd{\ C-h k} (or you can use the Help menu in the
viper.texi(,2074) menu bar, if Emacs runs under X).
viper.texi(,2075) 
viper.texi(,2076) Viper users can also change bindings on a per major mode basis.  As with
viper.texi(,2077) global bindings, this can be done separately for each of the three main Viper
viper.texi(,2078) states.  To this end, Viper provides the function
viper.texi(,2079) @code{viper-modify-major-mode}.
viper.texi(,2080) @findex @code{viper-modify-major-mode}
viper.texi(,2081) 
viper.texi(,2082) To modify keys in Emacs state for @code{my-favorite-major-mode}, the user
viper.texi(,2083) needs to create a sparse keymap, say, @code{my-fancy-map}, bind whatever
viper.texi(,2084) keys necessary in that keymap, and put
viper.texi(,2085) 
viper.texi(,2086) @example
viper.texi(,2087) (viper-modify-major-mode 'dired-mode 'emacs-state my-fancy-map)
viper.texi(,2088) @end example
viper.texi(,2089) 
viper.texi(,2090) @noindent
viper.texi(,2091) in @file{~/.viper}.  To do the same in Vi and Insert states, you should use
viper.texi(,2092) @code{vi-state} and @code{insert-state}.  Changes in Insert state are also
viper.texi(,2093) in effect in Replace state.  For instance, suppose that the user wants to
viper.texi(,2094) use @kbd{dd} in Vi state under Dired mode to delete files, @kbd{u} to unmark
viper.texi(,2095) files, etc.  The following code in @file{~/.viper} will then do the job:
viper.texi(,2096) 
viper.texi(,2097) @example
viper.texi(,2098) (setq my-dired-modifier-map (make-sparse-keymap))
viper.texi(,2099) (define-key my-dired-modifier-map "dd" 'dired-flag-file-deletion)
viper.texi(,2100) (define-key my-dired-modifier-map "u" 'dired-unmark)
viper.texi(,2101) (viper-modify-major-mode 'dired-mode 'vi-state my-dired-modifier-map)
viper.texi(,2102) @end example
viper.texi(,2103) 
viper.texi(,2104) A Vi purist may want to modify Emacs state under Dired mode so that
viper.texi(,2105) @kbd{k}, @kbd{l}, etc., will move around in directory buffers, as in
viper.texi(,2106) Vi.  Although this is not recommended, as these keys are bound to useful
viper.texi(,2107) Dired functions, the trick can be accomplished via the following code:
viper.texi(,2108) 
viper.texi(,2109) @example
viper.texi(,2110) (setq my-dired-vi-purist-map (make-sparse-keymap))
viper.texi(,2111) (define-key my-dired-vi-purist-map "k" 'viper-previous-line)
viper.texi(,2112) (define-key my-dired-vi-purist-map "l" 'viper-forward-char)
viper.texi(,2113) (viper-modify-major-mode 'dired-mode 'emacs-state my-dired-vi-purist-map)
viper.texi(,2114) @end example
viper.texi(,2115) 
viper.texi(,2116) Yet another way to customize key bindings in a major mode is to edit the
viper.texi(,2117) list @code{viper-major-mode-modifier-list} using the customization widget.
viper.texi(,2118) @vindex @code{viper-major-mode-modifier-list}
viper.texi(,2119) (This variable is in the Viper-misc customization group.)
viper.texi(,2120) The elements of this list are triples of the form: (major-mode viper-state
viper.texi(,2121) keymap), where the keymap contains bindings that are supposed to be active
viper.texi(,2122) in the given major mode and the given viper-state.
viper.texi(,2123) 
viper.texi(,2124) Effects similar to key binding changes can be achieved by defining Vi
viper.texi(,2125) keyboard macros using the Ex commands @kbd{:map} and @kbd{:map!}.  The
viper.texi(,2126) difference is that multi-key Vi macros do not override the keys they are
viper.texi(,2127) bound to, unless these keys are typed in quick succession.  So, with macros,
viper.texi(,2128) one can use the normal keys alongside with the macros.  If per-mode
viper.texi(,2129) modifications are needed, the user can try both ways and see which one is
viper.texi(,2130) more convenient.
viper.texi(,2131) @findex @kbd{:map}
viper.texi(,2132) @xref{Vi Macros}, for details.
viper.texi(,2133) 
viper.texi(,2134) Note: in major modes that come up in @emph{Emacs state} by default, the
viper.texi(,2135) aforesaid modifications may not take place immediately (but only after the
viper.texi(,2136) buffer switches to some other Viper state and then back to Emacs state).  To
viper.texi(,2137) avoid this, one should add @code{viper-change-state-to-emacs} to an
viper.texi(,2138) appropriate hook of that major mode.  (Check the function
viper.texi(,2139) @code{viper-set-hooks} in @file{viper.el} for examples.)  However, if you
viper.texi(,2140) did not set @code{viper-always} to @code{nil}, chances are that you won't
viper.texi(,2141) need to perform the above procedure, because Viper will take care of most
viper.texi(,2142) useful defaults.
viper.texi(,2143) 
viper.texi(,2144) 
viper.texi(,2145) Finally, Viper has a facility that lets the user define per-buffer
viper.texi(,2146) bindings, i.e., bindings that are in effect in some specific buffers
viper.texi(,2147) only.  Unlike per-mode bindings described above, per-buffer bindings can be
viper.texi(,2148) defined based on considerations other than the major mode.  This is done
viper.texi(,2149) via the function @code{viper-add-local-keys}, which lets one specify bindings
viper.texi(,2150) that should be in effect in the current buffer only and for a specific Viper
viper.texi(,2151) state.  For instance,
viper.texi(,2152) @lisp
viper.texi(,2153) (viper-add-local-keys 'vi-state '(("ZZ" .@: TeX-command-master)
viper.texi(,2154)                                  ("ZQ" .@: viper-save-kill-buffer)))
viper.texi(,2155) @end lisp
viper.texi(,2156) @noindent
viper.texi(,2157) redefines @kbd{ZZ} to invoke @code{TeX-command-master} in @code{vi-state}
viper.texi(,2158) and @kbd{ZQ} to save-then-kill the current buffer.  These bindings take
viper.texi(,2159) effect only in the buffer where this command is executed.  The typical use
viper.texi(,2160) of this function is to execute the above expression from within a function
viper.texi(,2161) that is included in a hook to some major mode.  For instance, the above
viper.texi(,2162) expression
viper.texi(,2163) could be called from a function, @code{my-tex-init}, which may be added to
viper.texi(,2164) @code{tex-mode-hook} as follows:
viper.texi(,2165) @lisp
viper.texi(,2166) (add-hook 'tex-mode-hook 'my-tex-init)
viper.texi(,2167) @end lisp
viper.texi(,2168) @noindent
viper.texi(,2169) When TeX mode starts, the hook is executed and the above Lisp expression is
viper.texi(,2170) evaluated.  Then, the bindings for @kbd{ZZ} and @kbd{ZQ} are changed in Vi
viper.texi(,2171) command mode for all buffers in TeX mode.
viper.texi(,2172) 
viper.texi(,2173) Another useful application is to bind @kbd{ZZ} to @code{send-mail}
viper.texi(,2174) in the Mail mode buffers (the specifics of this depend on which mail
viper.texi(,2175) package you are using, @code{rmail}, @code{mh-e}, @code{vm}, etc.
viper.texi(,2176) For instance, here is how to do this for @code{mh-e}, the Emacs interface
viper.texi(,2177) to MH:
viper.texi(,2178) @lisp
viper.texi(,2179) (defun mh-add-vi-keys ()
viper.texi(,2180)   "Set up ZZ for MH-e and XMH."
viper.texi(,2181)   (viper-add-local-keys 'vi-state '(("ZZ" .@: mh-send-letter))))
viper.texi(,2182) (add-hook 'mh-letter-mode-hook 'mh-add-vi-keys)
viper.texi(,2183) @end lisp
viper.texi(,2184) 
viper.texi(,2185) You can also use @code{viper-add-local-keys} to set per buffer
viper.texi(,2186) bindings in Insert state and Emacs state by passing as a parameter the
viper.texi(,2187) symbols @code{insert-state} and @code{emacs-state}, respectively.
viper.texi(,2188) As with global bindings, customized local bindings done to Emacs state
viper.texi(,2189) are not inherited by Insert state.
viper.texi(,2190) 
viper.texi(,2191) On rare occasions, local keys may be added by mistake.  Usually this is done
viper.texi(,2192) indirectly, by invoking a major mode that adds local keys (e.g.,
viper.texi(,2193) @code{shell-mode} redefines @key{RET}).  In such a case, exiting the wrong
viper.texi(,2194) major mode won't rid you from unwanted local keys, since these keys are
viper.texi(,2195) local to Viper state and the current buffer, not to the major mode.
viper.texi(,2196) In such situations, the remedy is to type @kbd{M-x viper-zap-local-keys}.
viper.texi(,2197) 
viper.texi(,2198) So much about Viper-specific bindings.
viper.texi(,2199) @xref{Customization,,Customization,emacs,The GNU Emacs
viper.texi(,2200) Manual}, and the Emacs quick reference card for the general info on key
viper.texi(,2201) bindings in Emacs.
viper.texi(,2202) 
viper.texi(,2203) @vindex @code{function-key-map}
viper.texi(,2204) @vindex @code{viper-vi-global-user-map}
viper.texi(,2205) @vindex @code{viper-insert-global-user-map}
viper.texi(,2206) @vindex @code{viper-emacs-global-user-map}
viper.texi(,2207) @findex @code{viper-add-local-keys}
viper.texi(,2208) @findex @code{viper-zap-local-keys}
viper.texi(,2209) 
viper.texi(,2210) @node Packages that Change Keymaps,Viper Specials,Key Bindings,Customization
viper.texi(,2211) @subsection Packages that Change Keymaps
viper.texi(,2212) @cindex C-c and Viper
viper.texi(,2213) @cindex Viper and C-c
viper.texi(,2214) 
viper.texi(,2215) Viper is designed to coexist with all major and minor modes of Emacs.  This
viper.texi(,2216) means that bindings set by those modes are generally available with Viper
viper.texi(,2217) (unless you explicitly prohibit them by setting
viper.texi(,2218) @code{viper-want-emacs-keys-in-vi} and @code{viper-want-emacs-keys-in-insert} to
viper.texi(,2219) @code{nil}).
viper.texi(,2220) If @code{viper-always} is set to @code{t} (which is the default), Viper
viper.texi(,2221) will try to bring each buffer 
viper.texi(,2222) in the Viper state that is most appropriate for that buffer.
viper.texi(,2223) Usually, this would be the Vi state, but sometimes it could be the Insert
viper.texi(,2224) state or the Emacs state.
viper.texi(,2225) 
viper.texi(,2226) Some major mode bindings will necessarily be overwritten by Viper.  Indeed, in
viper.texi(,2227) Vi state, most of the 1-character keys are used for Vi-style editing.  This
viper.texi(,2228) usually causes no problems because most packages designed for editing files
viper.texi(,2229) typically do not bind such keys.  Instead, they use key sequences that start
viper.texi(,2230) with @kbd{C-x} and @kbd{C-c}.  This is why it was so important for us to
viper.texi(,2231) free up @kbd{C-x} and @kbd{C-c}.
viper.texi(,2232) It is common for language-specific major modes to bind @key{TAB} and
viper.texi(,2233) @kbd{C-j} (the line feed) keys to various formatting functions.  This is
viper.texi(,2234) extremely useful, but may require some getting used to for a Vi user.  If you
viper.texi(,2235) decide that this feature is not for you, you can re-bind these keys as
viper.texi(,2236) explained earlier (@pxref{Customization}).
viper.texi(,2237) 
viper.texi(,2238) Binding for @key{TAB} is one of the most unusual aspects of Viper for many
viper.texi(,2239) novice users.  In Emacs, @key{TAB} is used to format text and programs, and
viper.texi(,2240) is extremely useful.  For instance, hitting @key{TAB} causes the current
viper.texi(,2241) line to be re-indented in accordance with the context.  In programming,
viper.texi(,2242) this is very important, since improper automatic indentation would
viper.texi(,2243) immediately alert the programmer to a possible error.  For instance, if a
viper.texi(,2244) @kbd{)} or a @kbd{"} is missing somewhere above the current
viper.texi(,2245) line, @key{TAB} is likely to mis-indent the line.
viper.texi(,2246) 
viper.texi(,2247) For this reason, Viper doesn't change the standard Emacs binding of
viper.texi(,2248) @key{TAB}, thereby sacrificing Vi compatibility
viper.texi(,2249) (except for users at level 1).  Instead, in Viper, the key
viper.texi(,2250) @kbd{S-tab} (shift+ tab) is chosen to emulate Vi's @key{TAB}.
viper.texi(,2251) 
viper.texi(,2252) We should note that on some non-windowing terminals, Shift doesn't modify
viper.texi(,2253) the @key{TAB} key, so @kbd{S-tab} behaves as if it were @key{TAB}.  In such
viper.texi(,2254) a case, you will have to bind @code{viper-insert-tab} to some other
viper.texi(,2255) convenient key.
viper.texi(,2256) 
viper.texi(,2257) Some packages, notably Dired, Gnus, Info, etc., attach special meaning to
viper.texi(,2258) common keys like @key{SPC}, @kbd{x}, @kbd{d}, @kbd{v}, and others.  This
viper.texi(,2259) means that Vi command state is inappropriate for working with these
viper.texi(,2260) packages.  Fortunately, these modes operate on read-only buffers and are
viper.texi(,2261) designed not for editing files, but for special-purpose browsing, reading
viper.texi(,2262) news, mail, etc., and Vi commands are meaningless in these situations.  For
viper.texi(,2263) this reason, Viper doesn't force Vi state on such major modes---it
viper.texi(,2264) brings them in Emacs state.  You can switch to Vi state by typing @kbd{C-z}
viper.texi(,2265) if, for instance, you want to do Vi-style search in a buffer (although,
viper.texi(,2266) usually, incremental search, which is bound to @kbd{C-s}, is sufficient in
viper.texi(,2267) these situations).  But you should then switch back to Emacs state if you
viper.texi(,2268) plan to continue using these major modes productively.  You can also switch
viper.texi(,2269) to Vi temporarily, to execute just one command.  This is done by typing
viper.texi(,2270) @kbd{C-c \}.  (In some of these modes, @kbd{/} and @kbd{:} are bound
viper.texi(,2271) Vi-style, unless these keys perform essential duties.)
viper.texi(,2272) 
viper.texi(,2273) If you would like certain major modes to come up in Emacs state rather than
viper.texi(,2274) Vi state (but Viper thinks otherwise), you should put these major modes
viper.texi(,2275) on the @code{viper-emacs-state-mode-list} list and delete them from
viper.texi(,2276) @code{viper-vi-state-mode-list}.
viper.texi(,2277) Likewise, you can force Viper's Insert state on a major mode by putting it
viper.texi(,2278) in @code{viper-insert-state-mode-list}.
viper.texi(,2279) @vindex @code{viper-emacs-state-mode-list}
viper.texi(,2280) @vindex @code{viper-insert-state-mode-list}
viper.texi(,2281) @vindex @code{viper-vi-state-mode-list}
viper.texi(,2282) 
viper.texi(,2283) It is also possible to impose Vi on some major modes, even though they may
viper.texi(,2284) bind common keys to specialized commands.  This might make sense for modes
viper.texi(,2285) that bind only a small number of common keys.  For instance, Viper subverts
viper.texi(,2286) the Shell mode by changing the bindings for @kbd{C-m} and @kbd{C-d} using
viper.texi(,2287) @code{viper-add-local-keys} described in section on customization
viper.texi(,2288) (@pxref{Customization}).
viper.texi(,2289) 
viper.texi(,2290) In some cases, some @emph{minor} modes might override certain essential
viper.texi(,2291) bindings in Vi command state.  This is not a big priblem because this
viper.texi(,2292) can happen only in the beginning, when the minor mode kicks in.  Typing
viper.texi(,2293) @code{M-x viper-mode} will correct the situation.  Viper knows about
viper.texi(,2294) several such minor modes and takes care of them, so the above trick
viper.texi(,2295) is usually not necessary.  If you find that some minor mode, e.g.,
viper.texi(,2296) @code{nasty-mode.el} interferes with Viper, putting the following in
viper.texi(,2297) @file{.viper} should fix the problem:
viper.texi(,2298) @lisp
viper.texi(,2299) (viper-harness-minor-mode "nasty-mode")
viper.texi(,2300) @end lisp
viper.texi(,2301) @noindent
viper.texi(,2302) The argument to @code{viper-harness-minor-mode} is the name of the file for the
viper.texi(,2303) offending minor mode with the suffixes @file{.el} and @file{.elc} removed.
viper.texi(,2304) 
viper.texi(,2305) It may not be always obvious which minor mode is at fault.  The only
viper.texi(,2306) guidance here is to look into the file that defines the minor mode you are
viper.texi(,2307) suspecting, say @code{nasty-mode.el}, and see if it has a variable called
viper.texi(,2308) @code{nasty-mode-map}.  Then check if there is a statement of the form
viper.texi(,2309) @lisp
viper.texi(,2310) (define-key nasty-mode-map key function)
viper.texi(,2311) @end lisp
viper.texi(,2312) @noindent
viper.texi(,2313) that binds the misbehaving
viper.texi(,2314) keys.  If so, use the above line to harness @code{nasty-mode}.  If your
viper.texi(,2315) suspicion is wrong, no harm is done if you harness a minor mode that
viper.texi(,2316) doesn't need to be harnessed.
viper.texi(,2317) 
viper.texi(,2318) @vindex @code{viper-want-emacs-keys-in-vi}
viper.texi(,2319) @vindex @code{viper-want-emacs-keys-in-insert}
viper.texi(,2320) @vindex @code{viper-always}
viper.texi(,2321) @findex @code{viper-set-hooks}
viper.texi(,2322) @findex @code{viper-mode}
viper.texi(,2323) @findex @code{viper-harness-minor-mode}
viper.texi(,2324) @findex @code{remove-hook}
viper.texi(,2325) @findex @code{add-hook}
viper.texi(,2326) 
viper.texi(,2327) @node Viper Specials,Vi Macros,Packages that Change Keymaps,Customization
viper.texi(,2328) @section Viper Specials
viper.texi(,2329) 
viper.texi(,2330) Viper extends Vi with a number of useful features.  This includes various
viper.texi(,2331) search functions, histories of search strings, Ex commands, insertions, and
viper.texi(,2332) Vi's destructive commands.  In addition, Viper supports file name completion
viper.texi(,2333) and history, completion of Ex commands and variables, and many other
viper.texi(,2334) features.  Some of these features are explained in detail elsewhere in this
viper.texi(,2335) document.  Other features are explained here.
viper.texi(,2336) 
viper.texi(,2337) @table @code
viper.texi(,2338) @item (viper-buffer-search-enable)
viper.texi(,2339) @item viper-buffer-search-char nil
viper.texi(,2340) Enable buffer search.  Explicit call to @code{viper-buffer-search-enable}
viper.texi(,2341) sets @code{viper-buffer-search-char} to @kbd{g}.  Alternatively, the user can
viper.texi(,2342) set @code{viper-buffer-search-char} in @file{.viper} to a key sequence
viper.texi(,2343) to be used for buffer search.  There is no need to call
viper.texi(,2344) @code{viper-buffer-search-enable} in that case.
viper.texi(,2345) @findex @code{viper-buffer-search-enable}
viper.texi(,2346) @vindex @code{viper-buffer-search-char}
viper.texi(,2347) @item viper-toggle-search-style
viper.texi(,2348) This function, bound to @kbd{C-c /}, lets one toggle case-sensitive and
viper.texi(,2349) case-insensitive search, and also switch between plain vanilla search and
viper.texi(,2350) search via regular expressions.  Without the prefix argument, the user is
viper.texi(,2351) asked which mode to toggle.  With prefix argument 1, this toggles
viper.texi(,2352) case-sensitivity.  With prefix argument 2, regular expression/vanilla search
viper.texi(,2353) will be toggled.
viper.texi(,2354) 
viper.texi(,2355) However, we found that the most convenient way to toggle
viper.texi(,2356) these options is to bind a Vi macro to
viper.texi(,2357) bind @kbd{//} to toggles case sensitivity and to @kbd{///} to toggles
viper.texi(,2358) vanilla search.  Thus, quickly hitting @kbd{/} twice will switch Viper from
viper.texi(,2359) case sensitive search to case-insensitive.  Repeating this once again will
viper.texi(,2360) restore the original state.  Likewise, quickly hitting @kbd{/} three times
viper.texi(,2361) will switch you from vanilla-style search to search via regular expressions.
viper.texi(,2362) If you hit something other than @kbd{/} after the first @kbd{/} or if the
viper.texi(,2363) second @kbd{/} doesn't follow quickly enough, then Viper will issue the
viper.texi(,2364) usual prompt @kbd{/} and will wait for input, as usual in Vi.
viper.texi(,2365) If you don't like this behavior, you can ``unrecord'' these macros in your
viper.texi(,2366) @file{~/.viper} file.  For instance, if you don't like the above feature, put
viper.texi(,2367) this in @file{~/.viper}:
viper.texi(,2368) @example
viper.texi(,2369) (viper-set-searchstyle-toggling-macros 'undefine)
viper.texi(,2370) @end example
viper.texi(,2371) @findex @code{viper-set-searchstyle-toggling-macros}
viper.texi(,2372) 
viper.texi(,2373) @item Vi-isms in Emacs state
viper.texi(,2374) Some people find it useful to use the Vi-style search key, `/', to invoke
viper.texi(,2375) search in modes which Viper leaves in emacs-state.  These modes are:
viper.texi(,2376) @code{dired-mode}, @code{mh-folder-mode}, @code{gnus-group-mode},
viper.texi(,2377) @code{gnus-summary-mode}, @code{Info-mode}, and @code{Buffer-menu-mode}
viper.texi(,2378) (more may be added in the future).  So, in the above modes, Viper binds `/'
viper.texi(,2379) so that it will behave Vi-style.  Furthermore, in those major modes, Viper
viper.texi(,2380) binds `:' to invoke ex-style commands, like in vi-state.  And, as described
viper.texi(,2381) above, `//' and `///' get bound to Vi-style macros that toggle
viper.texi(,2382) case-insensitivity and regexp-search.
viper.texi(,2383) 
viper.texi(,2384) If you don't like these features---which I don't really understand---you
viper.texi(,2385) can unbind `/' and `:' in @code{viper-dired-modifier-map} (for Dired) or in
viper.texi(,2386) @code{viper-slash-and-colon-map}, for other modes.
viper.texi(,2387) @vindex @code{viper-slash-and-colon-map}
viper.texi(,2388) @vindex @code{viper-dired-modifier-map}
viper.texi(,2389) 
viper.texi(,2390) To unbind the macros `//' and `///' for a major mode where you feel they
viper.texi(,2391) are undesirable, execute @code{viper-set-emacs-state-searchstyle-macros} with a
viper.texi(,2392) non-nil argument.  This can be done either interactively, by supplying a
viper.texi(,2393) prefix argument, or by placing
viper.texi(,2394) @example
viper.texi(,2395) (viper-set-emacs-state-searchstyle-macros 'undefine)
viper.texi(,2396) @end example
viper.texi(,2397) @findex @code{viper-set-emacs-state-searchstyle-macros}
viper.texi(,2398) in the hook to the major mode (e.g., @code{dired-mode-hook}).
viper.texi(,2399) @xref{Vi Macros}, for more information on Vi macros.
viper.texi(,2400) 
viper.texi(,2401) @item viper-heading-start
viper.texi(,2402) @item viper-heading-end
viper.texi(,2403) @cindex headings
viper.texi(,2404) @cindex sections
viper.texi(,2405) @cindex paragraphs
viper.texi(,2406) @cindex sentences
viper.texi(,2407) Regular Expressions for @kbd{[[} and @kbd{]]}.  Note that Emacs defines
viper.texi(,2408) Regexps for paragraphs and sentences.  @xref{Paragraphs,,Paragraphs and
viper.texi(,2409) Sentences,emacs,The GNU Emacs Manual}, for details.
viper.texi(,2410) @item M-x viper-set-expert-level
viper.texi(,2411) @findex @code{viper-set-expert-level}
viper.texi(,2412) Change your user level interactively.
viper.texi(,2413) @item viper-smart-suffix-list  '("" "tex" "c" "cc" "el" "p")
viper.texi(,2414) @vindex @code{viper-smart-suffix-list}
viper.texi(,2415) Viper supports Emacs-style file completion when it prompts the user for a
viper.texi(,2416) file name.  However, in many cases, the same directory may contain files
viper.texi(,2417) with identical prefix but different suffixes, e.g., prog.c, prog.o,
viper.texi(,2418) paper.tex, paper.dvi.  In such cases, completion will stop at the `.'.
viper.texi(,2419) If the above variable is a list of strings representing suffixes, Viper will
viper.texi(,2420) try these suffixes
viper.texi(,2421) in the order listed and will check if the corresponding file exists.
viper.texi(,2422) 
viper.texi(,2423) For instance, if completion stopped at `paper.'@: and the user typed
viper.texi(,2424) @key{RET},
viper.texi(,2425) then Viper will check if the files `paper.', `paper.tex', `paper.c', etc., exist.
viper.texi(,2426) It will take the first such file.  If no file exists, Viper will give a chance
viper.texi(,2427) to complete the file name by typing the appropriate suffix.  If `paper.'@: was
viper.texi(,2428) the intended file name, hitting return will accept it.
viper.texi(,2429) 
viper.texi(,2430) To turn this feature off, set the above variable to @code{nil}.
viper.texi(,2431) 
viper.texi(,2432) @item viper-insertion-ring-size  14
viper.texi(,2433) @vindex @code{viper-insertion-ring-size}
viper.texi(,2434) @cindex Insertion ring
viper.texi(,2435) Viper remembers what was previously inserted in Insert and Replace states.
viper.texi(,2436) Several such recent insertions are kept in a special ring of strings of size
viper.texi(,2437) @code{viper-insertion-ring-size}.
viper.texi(,2438) If you enter Insert or Replace state you can reinsert strings from this
viper.texi(,2439) ring by typing @kbd{C-c M-p} or @kbd{C-c M-n}.  The former will search the
viper.texi(,2440) ring in
viper.texi(,2441) the direction of older insertions, and the latter will search in
viper.texi(,2442) the direction of newer insertions.  Hitting @kbd{C-c M-p} or @kbd{C-c M-n}
viper.texi(,2443) in succession
viper.texi(,2444) will undo the previous insertion from the ring and insert the next item on
viper.texi(,2445) the ring.  If a larger ring size is needed, change the value of the above
viper.texi(,2446) variable in the @file{~/.viper} file.
viper.texi(,2447) 
viper.texi(,2448) Since typing these sequences of keys may be tedious, it is suggested that the
viper.texi(,2449) user should bind a function key, such as @kbd{f31}, as follows:
viper.texi(,2450) @example
viper.texi(,2451) (define-key viper-insert-global-user-map [f31]
viper.texi(,2452)             'viper-insert-prev-from-insertion-ring)
viper.texi(,2453) @end example
viper.texi(,2454) This binds @kbd{f31} (which is usually @kbd{R11} on a Sun workstation)
viper.texi(,2455) to the function that inserts the previous string in the insertion history.
viper.texi(,2456) To rotate the history in the opposite
viper.texi(,2457) direction, you can either bind an unused key to
viper.texi(,2458) @code{viper-insert-next-from-insertion-ring} or hit any digit (1 to 9) then
viper.texi(,2459) @kbd{f31}.
viper.texi(,2460) 
viper.texi(,2461) One should not bind the above functions to @kbd{M-p} or @kbd{M-n}, since
viper.texi(,2462) this will interfere with the Minibuffer histories and, possibly, other
viper.texi(,2463) major modes.
viper.texi(,2464) 
viper.texi(,2465) @item viper-command-ring-size  14
viper.texi(,2466) @vindex @code{viper-command-ring-size}
viper.texi(,2467) @cindex Destructive command ring
viper.texi(,2468) @cindex Destructive command history
viper.texi(,2469) Viper keeps track of the recent history of destructive
viper.texi(,2470) commands, such as @kbd{dw}, @kbd{i}, etc.
viper.texi(,2471) In Vi state,
viper.texi(,2472) the most recent command can be re-executed by hitting `@kbd{.}', as in Vi.
viper.texi(,2473) However, repeated typing @kbd{C-c M-p} will cause Viper to show the
viper.texi(,2474) previous destructive commands in the minibuffer.  Subsequent hitting `@kbd{.}'
viper.texi(,2475) will execute the command that was displayed last.
viper.texi(,2476) The key @kbd{C-c M-n} will cycle through the command history in the
viper.texi(,2477) opposite direction.
viper.texi(,2478) Since typing @kbd{C-c M-p} may be tedious, it is more convenient to bind an
viper.texi(,2479) appropriate function to an unused function key on the keyboard and use that
viper.texi(,2480) key.  For instance, the following
viper.texi(,2481) @example
viper.texi(,2482) (define-key viper-vi-global-user-map [f31]
viper.texi(,2483)             'viper-prev-destructive-command)
viper.texi(,2484) @end example
viper.texi(,2485) binds the key @kbd{f31} (which is usually @kbd{R11} on a Sun workstation)
viper.texi(,2486) to the function that searches the command history in the direction of older
viper.texi(,2487) commands.  To search in the opposite
viper.texi(,2488) direction, you can either bind an unused key to
viper.texi(,2489) @code{viper-next-destructive-command} or hit any digit (1 to 9) then @kbd{f31}.
viper.texi(,2490) 
viper.texi(,2491) One should not bind the above functions to @kbd{M-p} or @kbd{M-n}, since
viper.texi(,2492) this will interfere with the Minibuffer histories and, possibly, other
viper.texi(,2493) major modes.
viper.texi(,2494) 
viper.texi(,2495) @item viper-minibuffer-vi-face  'viper-minibuffer-vi-face
viper.texi(,2496) @item viper-minibuffer-insert-face  'viper-minibuffer-insert-face
viper.texi(,2497) @item viper-minibuffer-emacs-face  'viper-minibuffer-emacs-face
viper.texi(,2498) These faces control the appearance of the minibuffer text in the
viper.texi(,2499) corresponding Viper states.  You can change the appearance of these faces
viper.texi(,2500) through Emacs' customization widget, which is accessible through the
viper.texi(,2501) menubar.
viper.texi(,2502) 
viper.texi(,2503) Viper is located in this widget under the @emph{Emulations} customization
viper.texi(,2504) subgroup of the @emph{Editing} group.  All Viper faces are grouped together
viper.texi(,2505) in Viper's @emph{Highlighting} customization subgroup.
viper.texi(,2506) 
viper.texi(,2507) Note that only the text you type in is affected by the above faces.
viper.texi(,2508) Prompts and Minibuffer messages are not affected.
viper.texi(,2509) 
viper.texi(,2510) Purists who do not like adornments in the minibuffer can always zap them by
viper.texi(,2511) putting
viper.texi(,2512) @example
viper.texi(,2513) (copy-face 'default 'viper-minibuffer-vi-face)
viper.texi(,2514) (copy-face 'default 'viper-minibuffer-insert-face)
viper.texi(,2515) (copy-face 'default 'viper-minibuffer-emacs-face)
viper.texi(,2516) @end example
viper.texi(,2517) in the @file{~/.viper} file or through the customization widget, as
viper.texi(,2518) described above.  However, in that case, the user will not have any
viper.texi(,2519) indication of the current Viper state in the minibuffer.  (This is important
viper.texi(,2520) if the user accidentally switches to another Viper state by typing @key{ESC} or
viper.texi(,2521) @kbd{C-z}).
viper.texi(,2522) @item M-x viper-go-away
viper.texi(,2523) @findex @code{viper-go-away}
viper.texi(,2524) Make Viper disappear from the face of your running Emacs instance.  If your
viper.texi(,2525) fingers start aching again, @kbd{M-x viper-mode} might save your day.
viper.texi(,2526) @item M-x toggle-viper-mode
viper.texi(,2527) @findex @code{toggle-viper-mode}
viper.texi(,2528) Toggle Viperization of Emacs on and off.
viper.texi(,2529) @end table
viper.texi(,2530) 
viper.texi(,2531) @cindex Multifile documents and programs
viper.texi(,2532) 
viper.texi(,2533) Viper provides some support for multi-file documents and programs.
viper.texi(,2534) If a document consists of several files we can designate one of them as a
viper.texi(,2535) master and put the following at the end of that file:
viper.texi(,2536) @lisp
viper.texi(,2537) ;;; Local Variables:
viper.texi(,2538) ;;; eval: (viper-setup-master-buffer "file1" "file2" "file3" "file4")
viper.texi(,2539) ;;; End:
viper.texi(,2540) @end lisp
viper.texi(,2541) @noindent
viper.texi(,2542) where @code{file1} to @code{file4} are names of files related to the master
viper.texi(,2543) file.  Next time, when the master file is visited, the command
viper.texi(,2544) @code{viper-setup-master-buffer} will be evaluated and the above files will
viper.texi(,2545) be associated with the master file.  Then, the new Ex command
viper.texi(,2546) @kbd{:RelatedFile} (abbr.@: @kbd{:R}) will display files 1 to 4 one after
viper.texi(,2547) another, so you can edit them.  If a file is not in any Emacs buffer, it
viper.texi(,2548) will be visited.  The command @kbd{PreviousRelatedFile} (abbr., @kbd{:P})
viper.texi(,2549) goes through the file list in the opposite direction.
viper.texi(,2550) @findex @kbd{:RelatedFile}
viper.texi(,2551) @findex @kbd{:PreviousRelatedFile}
viper.texi(,2552) 
viper.texi(,2553) These commands are akin to @kbd{:n} and @kbd{:N}, but they allow the user to
viper.texi(,2554) focus on relevant files only.
viper.texi(,2555) 
viper.texi(,2556) Note that only the master file needs to have the aforementioned block of
viper.texi(,2557) commands.  Also, ";;;" above can be replaced by some other
viper.texi(,2558) markers.  Semicolon is good for Lisp programs, since it is considered a
viper.texi(,2559) comment designator there.  For LaTeX, this could be "%%%", and for C the
viper.texi(,2560) above block should be commented out.
viper.texi(,2561) 
viper.texi(,2562) Even though these commands are sometimes useful, they are no substitute for
viper.texi(,2563) the powerful @emph{tag table} facility of Emacs.  Viper's @kbd{:tag} command
viper.texi(,2564) in a primitive interface to Emacs tags.  @xref{Tags,Tags,Tags,emacs,
viper.texi(,2565) The Gnu Emacs Manual}, for more information on tags.
viper.texi(,2566) 
viper.texi(,2567) The following two commands are normally bound to a mouse click and are part
viper.texi(,2568) of Viper.  They work only if Emacs runs as an application under X
viper.texi(,2569) Windows (or under some other window system for which a port of GNU Emacs 20
viper.texi(,2570) is available).  Clicking the mouse when Emacs is invoked in an Xterm window
viper.texi(,2571) (using @code{emacs -nw}) will do no good.
viper.texi(,2572) 
viper.texi(,2573) @table @code
viper.texi(,2574) @cindex mouse
viper.texi(,2575) @cindex mouse-search
viper.texi(,2576) @item viper-mouse-search-key  (meta shift 1)
viper.texi(,2577) @vindex @code{viper-mouse-insert-key}
viper.texi(,2578) This variable controls the @emph{mouse-search} feature of Viper.  The
viper.texi(,2579) default value
viper.texi(,2580) states that holding Meta and Shift keys while clicking mouse button 1
viper.texi(,2581) should initiate search for a region under the mouse pointer (defined
viper.texi(,2582) below).  This command can take a prefix argument, which indicates the
viper.texi(,2583) occurrence of the pattern to search for.
viper.texi(,2584) 
viper.texi(,2585) Note: while loading initially, Viper binds this mouse action only if it is
viper.texi(,2586) not already bound to something else.  If you want to use the mouse-search
viper.texi(,2587) feature, and the @kbd{Meta-Shift-Mouse-1} mouse action is already bound to
viper.texi(,2588) something else, you can rebind the mouse-search feature by setting
viper.texi(,2589) @code{viper-mouse-search-key} to something else in your @code{~/.viper}
viper.texi(,2590) file:
viper.texi(,2591) @lisp
viper.texi(,2592) (setq viper-mouse-search-key '(meta 1))
viper.texi(,2593) @end lisp
viper.texi(,2594) This would bind mouse search to the action invoked by pressing the
viper.texi(,2595) Meta key and clicking mouse button 1.  The allowed values of
viper.texi(,2596) @code{viper-mouse-search-key} are lists that contain a mouse-button number
viper.texi(,2597) (1,2, or 3) and any combination of the words `control', `meta', and
viper.texi(,2598) `shift'.
viper.texi(,2599) 
viper.texi(,2600) If the requested mouse action (e.g., (meta 1)) is already taken for other
viper.texi(,2601) purposes then you have to confirm your intention by placing the following
viper.texi(,2602) command in @code{~/.viper} after setting @code{viper-mouse-search-key}:
viper.texi(,2603) @lisp
viper.texi(,2604) (viper-bind-mouse-search-key 'force)
viper.texi(,2605) @end lisp
viper.texi(,2606) 
viper.texi(,2607) You can also change this setting interactively, through the customization
viper.texi(,2608) widget of Emacs (type @kbd{:customize}).
viper.texi(,2609) 
viper.texi(,2610) The region that is chosen as a pattern to search for is determined as
viper.texi(,2611) follows.  If search is invoked via a single click, Viper chooses the region
viper.texi(,2612) that lies between the beginning of the ``word'' under the pointer (``word''
viper.texi(,2613) is understood in Vi sense) and the end of that word.  The only difference
viper.texi(,2614) with Vi's words is that in Lisp major modes `-' is considered an
viper.texi(,2615) alphanumeric symbol.  This is done for the convenience of working with Lisp
viper.texi(,2616) symbols, which often have an `-' in them.  Also, if you click on a
viper.texi(,2617) non-alphanumeric character that is not a word separator (in Vi sense) then
viper.texi(,2618) this character will also be considered alphanumeric, provided that it is
viper.texi(,2619) adjacent (from either side) to an alphanumeric character.  This useful
viper.texi(,2620) feature gives added control over the patterns selected by the mouse click.
viper.texi(,2621) 
viper.texi(,2622) On a double-click, the region is determined by the beginning of the current
viper.texi(,2623) Vi's ``Word'' (i.e., the largest non-separator chunk of text) and the End
viper.texi(,2624) of that ``Word'' (as determined by the @kbd{E} command).
viper.texi(,2625) 
viper.texi(,2626) On a triple-click, the region consists of the entire line where the click
viper.texi(,2627) occurred with all leading and trailing spaces and tabs removed.
viper.texi(,2628) 
viper.texi(,2629) @cindex mouse-insert
viper.texi(,2630) @item viper-mouse-insert-key (meta shift 2)
viper.texi(,2631) @vindex @code{viper-mouse-insert-key}
viper.texi(,2632) This variable controls the @emph{mouse-insert} feature of Viper.
viper.texi(,2633) The above default value states that
viper.texi(,2634) holding Meta and Shift keys while clicking mouse button 2
viper.texi(,2635) should insert the region surrounding the
viper.texi(,2636) mouse pointer.  The rules defining this region are the same as for
viper.texi(,2637) mouse-search.  This command takes an optional prefix argument, which
viper.texi(,2638) indicates how many such regions to snarf from the buffer and insert.  (In
viper.texi(,2639) case of a triple-click, the prefix argument is ignored.)
viper.texi(,2640) 
viper.texi(,2641) Note: while loading initially, Viper binds this mouse action only if it not
viper.texi(,2642) already bound to something else.  If you want to use this feature and the
viper.texi(,2643) default mouse action is already bound, you can rebind mouse-insert by
viper.texi(,2644) placing this command in @code{~/.viper}:
viper.texi(,2645) @lisp
viper.texi(,2646) (setq viper-mouse-insert-key '(meta 2))
viper.texi(,2647) @end lisp
viper.texi(,2648) If you want to bind mouse-insert to an action even if this action is
viper.texi(,2649) already taked for other purposes in Emacs, then you should add this command
viper.texi(,2650) to @code{~/.viper}, after setting @code{viper-mouse-insert-key}:
viper.texi(,2651) @lisp
viper.texi(,2652) (viper-bind-mouse-insert-key 'force)
viper.texi(,2653) @end lisp
viper.texi(,2654) 
viper.texi(,2655) This value can also be changed via the Emacs customization widget at the
viper.texi(,2656) menubar.
viper.texi(,2657) 
viper.texi(,2658) @item viper-multiclick-timeout
viper.texi(,2659) This variable controls the rate at which double-clicking must occur for the
viper.texi(,2660) purpose of mouse search and mouse insert.  By default, this is set to
viper.texi(,2661) @code{double-click-time} in Emacs and to
viper.texi(,2662) @code{mouse-track-multi-click-time} milliseconds in XEmacs.
viper.texi(,2663) @end table        
viper.texi(,2664) @kindex @kbd{S-Mouse-1}
viper.texi(,2665) @kindex @kbd{S-Mouse-2}
viper.texi(,2666) @kindex @kbd{meta shift button1up}
viper.texi(,2667) @kindex @kbd{meta shift button2up}
viper.texi(,2668) @vindex @code{viper-multiclick-timeout}
viper.texi(,2669) @findex @code{viper-mouse-click-insert-word}
viper.texi(,2670) @findex @code{viper-mouse-click-search-word}
viper.texi(,2671) 
viper.texi(,2672) Note: The above functions search and insert in the selected window of
viper.texi(,2673) the latest active frame.  This means that you can click in another window or
viper.texi(,2674) another frame and have search or insertion done in the frame and window you
viper.texi(,2675) just left.  This lets one use these functions in a multi-frame
viper.texi(,2676) configuration.  However, this may require some getting used to.  For
viper.texi(,2677) instance, if you are typing in a frame, A, and then move the mouse to frame
viper.texi(,2678) B and click to invoke mouse search, search (or insertion) will be performed
viper.texi(,2679) in frame A.  To perform search/insertion in frame B, you will first have to
viper.texi(,2680) shift focus there, which doesn't happen until you type a character or
viper.texi(,2681) perform some other action in frame B---mouse search doesn't shift focus.
viper.texi(,2682) 
viper.texi(,2683) If you decide that you don't like the above feature and always want
viper.texi(,2684) search/insertion be performed in the frame where the click occurs, don't
viper.texi(,2685) bind (and unbind, if necessary) @code{viper-mouse-catch-frame-switch} from
viper.texi(,2686) the mouse event it is bound to.
viper.texi(,2687) 
viper.texi(,2688) Mouse search is integrated with Vi-style search, so you can
viper.texi(,2689) repeat it with @kbd{n} and @kbd{N}.  It should be also noted that, while
viper.texi(,2690) case-sensitivity of search in Viper is controlled by the variable
viper.texi(,2691) @code{viper-case-fold-search}, the case of mouse search is
viper.texi(,2692) controlled by the Emacs variable @code{case-fold-search}, which may be set
viper.texi(,2693) differently from @code{viper-case-fold-search}.  Therefore, case-sensitivity
viper.texi(,2694) of mouse search may be different from that of the usual Vi-style search.
viper.texi(,2695) 
viper.texi(,2696) Finally, if the way Viper determines the word to be searched for or to be
viper.texi(,2697) inserted is not what you want, there is a variable,
viper.texi(,2698) @code{viper-surrounding-word-function}, which can be changed to indicate
viper.texi(,2699) another function for snarfing words out of the buffer.  The catch is that
viper.texi(,2700) you will then have to write such a function and make it known to your
viper.texi(,2701) Emacs.  The function @code{viper-surrounding-word} in @file{viper.el} can be
viper.texi(,2702) used as a guiding example.
viper.texi(,2703) 
viper.texi(,2704) @node Vi Macros, ,Viper Specials,Customization
viper.texi(,2705) @section Vi Macros
viper.texi(,2706) 
viper.texi(,2707) @cindex Vi macros
viper.texi(,2708) 
viper.texi(,2709) Viper supports much enhanced Vi-style macros and also facilitates the use
viper.texi(,2710) of Emacs-style macros.  To define a temporary macro, it is generally more
viper.texi(,2711) convenient to use Emacs keyboard macro facility.  Emacs keyboard macros are
viper.texi(,2712) usually defined anonymously, and the latest macro can be executed by typing
viper.texi(,2713) @kbd{C-x e} (or @kbd{*}, if Viper is in Vi state).  If you need to use several
viper.texi(,2714) temporary macros, Viper lets you save them to a
viper.texi(,2715) register (a lowercase letter); such macros can then be executed by typing
viper.texi(,2716) @kbd{@@a} in Vi state (if a macro was previously saved in register
viper.texi(,2717) @kbd{a}).
viper.texi(,2718) @xref{Macros and Registers}, for details.
viper.texi(,2719) 
viper.texi(,2720) If, however, you need to use a macro regularly, it must be given a
viper.texi(,2721) permanent name and saved.  Emacs manual explains how to do this, but
viper.texi(,2722) invocation of named Emacs macros is quite different from Vi's.  First,
viper.texi(,2723) invocation of permanent Emacs macros takes time because it requires typing
viper.texi(,2724) too many keys (to  a Vi user's taste, anyway).
viper.texi(,2725) Second, binding such macros to function keys, for
viper.texi(,2726) fast access, hogs valuable real estate on the keyboard.
viper.texi(,2727) 
viper.texi(,2728) Vi-style macros are better in that respect, since Vi lets the user overload
viper.texi(,2729) the meaning of key sequences: keys typed in fast succession are treated
viper.texi(,2730) specially, if this key sequence is bound to a macro.
viper.texi(,2731) 
viper.texi(,2732) Viper provides Vi-style keyboard macros through the usual Ex commands,
viper.texi(,2733) @kbd{:map} and 
viper.texi(,2734) @kbd{:map!}.  These macros are much more powerful in Viper than
viper.texi(,2735) they are in the original Vi and in other emulators.  This is because Viper
viper.texi(,2736) implements an enhanced vi-style
viper.texi(,2737) interface to the powerful Emacs keyboard macro facility.
viper.texi(,2738) 
viper.texi(,2739) First, any Emacs
viper.texi(,2740) command can be executed while defining a macro, not just the Vi
viper.texi(,2741) commands.  In particular, the user can invoke Emacs commands via @kbd{M-x
viper.texi(,2742) command-name} or by pressing various function keys on the keyboard.  One
viper.texi(,2743) can even use the mouse, although this is usually not useful and is not
viper.texi(,2744) recommended (and macros defined with the use of the mouse cannot be saved in
viper.texi(,2745) command history and in the startup file, for future use).
viper.texi(,2746) 
viper.texi(,2747) Macros defined by mixing Vi and Emacs commands are represented as
viper.texi(,2748) vectors.  So, don't be confused when you see one (usually through the
viper.texi(,2749) history of Ex commands).  For instance, if @kbd{gg} is defined by typing
viper.texi(,2750) @kbd{l}, the up-arrow key and @kbd{M-x next-line}, its definition will look
viper.texi(,2751) as follows in Emacs (in XEmacs, it looks slightly different, see below):
viper.texi(,2752) 
viper.texi(,2753) @example
viper.texi(,2754) [l up (meta x) n e x t - l i n e return]
viper.texi(,2755) @end example
viper.texi(,2756) 
viper.texi(,2757) Second, Viper macros are defined in a WYSIWYG style.  This means that
viper.texi(,2758) commands are executed as you type them, so you can see precisely what is
viper.texi(,2759) being defined.  Third, macros can be bound to arbitrary sequences of keys,
viper.texi(,2760) not just to printable keys.  For instance, one can define a macro that will
viper.texi(,2761) be invoked by hitting @kbd{f3} then @kbd{f2} function keys.  (The keys
viper.texi(,2762) @kbd{delete} and @kbd{backspace} are excluded; also, a macro invocation
viper.texi(,2763) sequence can't start with @key{ESC}.  Some other keys, such as @kbd{f1} and
viper.texi(,2764) @kbd{help}, can't be bound to macros under Emacs, since they
viper.texi(,2765) are bound in @code{key-translation-map}, which overrides any other binding
viper.texi(,2766) the user gives to keys.  In general, keys that have a binding in
viper.texi(,2767) @code{key-translation-map} can't be bound to a macro.)
viper.texi(,2768) 
viper.texi(,2769) Fourth, in Viper, one can define macros that are specific to a given
viper.texi(,2770) buffer, a given major mode, or macros that are defined for all buffers.  In
viper.texi(,2771) fact, the same macro name can have several different definitions: one
viper.texi(,2772) global, several definitions for various major modes, and
viper.texi(,2773) definitions for various specific buffers.  Buffer-specific definitions
viper.texi(,2774) override mode-specific definitions, which, in turn, override global
viper.texi(,2775) definitions.
viper.texi(,2776) 
viper.texi(,2777) As if all that is not enough, Viper (through its interface to Emacs
viper.texi(,2778) macros) lets the user define keyboard macros that ask for confirmation or
viper.texi(,2779) even prompt the user for input and then continue.  To do this, one should
viper.texi(,2780) type @kbd{C-x q} (for confirmation) or @kbd{C-u C-x q} (for prompt).
viper.texi(,2781) For details, @pxref{Kbd Macro Query,,Customization,emacs,The GNU Emacs
viper.texi(,2782) Manual} @refill
viper.texi(,2783) 
viper.texi(,2784) When the user finishes defining a macro (which is done by typing @kbd{C-x)} ---
viper.texi(,2785) a departure from Vi), you will be asked whether you want this
viper.texi(,2786) macro to be global, mode-specific, or buffer-specific.  You will also be
viper.texi(,2787) given a chance to save the macro in your @file{~/.viper} file.
viper.texi(,2788) This is the easiest way to save a macro and make
viper.texi(,2789) it permanently available.  If you work your startup files with bare hands,
viper.texi(,2790) here is how Viper saves the above macro so that it will be
viper.texi(,2791) available in Viper's Insert state (and Replace state) in buffer @code{my-buf}
viper.texi(,2792) only:
viper.texi(,2793) 
viper.texi(,2794) @example
viper.texi(,2795) (viper-record-kbd-macro "gg" 'insert-state
viper.texi(,2796)        [l up (meta x) n e x t - l i n e return]
viper.texi(,2797)        "my-buf")
viper.texi(,2798) @end example
viper.texi(,2799) 
viper.texi(,2800) @noindent
viper.texi(,2801) To do the same for Vi state and all buffers with the major mode
viper.texi(,2802) @code{cc-mode}, use:
viper.texi(,2803) 
viper.texi(,2804) @example
viper.texi(,2805) (viper-record-kbd-macro "gg" 'vi-state
viper.texi(,2806)        [l up (meta x) n e x t - l i n e return]
viper.texi(,2807)        'cc-mode)
viper.texi(,2808) @end example
viper.texi(,2809) 
viper.texi(,2810) @noindent
viper.texi(,2811) Both macro names and macro definitions are vectors of symbols that denote
viper.texi(,2812) keys on the keyboard.  Some keys, like @kbd{\}, @kbd{ }, or digit-keys must
viper.texi(,2813) be escaped with a backslash.  Modified keys are represented as lists.  For
viper.texi(,2814) instance, holding Meta and Control and pressing @kbd{f4} is represented as
viper.texi(,2815) @kbd{(control meta f4)}.
viper.texi(,2816) If all members of a vectors are printable characters (or sequences, such as
viper.texi(,2817) @kbd{\e}, @kbd{\t}, for @key{ESC} and @key{TAB}), then they can also be represented as
viper.texi(,2818) strings:
viper.texi(,2819) 
viper.texi(,2820) @example
viper.texi(,2821) (viper-record-kbd-macro "aa" 'vi-state  "aaa\e"  "my-buffer")
viper.texi(,2822) @end example
viper.texi(,2823) 
viper.texi(,2824) @noindent
viper.texi(,2825) Thus, typing @kbd{aa} fast in Vi state will switch Viper to Insert state
viper.texi(,2826) (due to the first @kbd{a}), insert @kbd{aa}, and then it will switch back to Vi
viper.texi(,2827) state.  All this will take effect only in the buffer named @code{my-buffer}.
viper.texi(,2828) 
viper.texi(,2829) Note that the last argument to @code{viper-record-kbd-macro} must be either a
viper.texi(,2830) string (a buffer name), a symbol representing a major mode, or @code{t};
viper.texi(,2831) the latter says that the macro is to be defined for all buffers
viper.texi(,2832) (which is how macros are defined in original Vi).
viper.texi(,2833) 
viper.texi(,2834) For convenience, Viper also lets you define Vi-style macros in its Emacs
viper.texi(,2835) state.  There is no Ex command, like @kbd{:map} and @kbd{:map!} for doing
viper.texi(,2836) this, but the user can include such a macro in the @file{~/.viper} file.  The
viper.texi(,2837) only thing is that the @code{viper-record-kbd-macro} command should specify
viper.texi(,2838) @code{emacs-state} instead of @code{vi-state} or @code{insert-state}.
viper.texi(,2839) 
viper.texi(,2840) The user can get rid of a macro either by using the Ex commands @kbd{:unmap}
viper.texi(,2841) and @kbd{:unmap!} or by issuing a call to @code{viper-unrecord-kbd-macro}.
viper.texi(,2842) The latter is more powerful, since it can delete macros even in
viper.texi(,2843) @code{emacs-state}.  However, @code{viper-unrecord-kbd-macro} is usually
viper.texi(,2844) needed only when the user needs to get rid of the macros that are already
viper.texi(,2845) predefined in Viper.
viper.texi(,2846) The syntax is:
viper.texi(,2847) @findex @code{viper-unrecord-kbd-macro}
viper.texi(,2848) @example
viper.texi(,2849) (viper-unrecord-kbd-macro macro state)
viper.texi(,2850) @end example
viper.texi(,2851) @noindent
viper.texi(,2852) The second argument must be @code{vi-state}, @code{insert-state}, or
viper.texi(,2853) @code{emacs-state}.  The first argument is a name of a macro.  To avoid
viper.texi(,2854) mistakes in specifying names of existing macros, type @kbd{M-x
viper.texi(,2855) viper-describe-kbd-macros} and use a name from the list displayed by this
viper.texi(,2856) command.
viper.texi(,2857) 
viper.texi(,2858) If an error occurs during macro definition, Emacs
viper.texi(,2859) aborts the process, and it must be repeated.  This is analogous to Vi,
viper.texi(,2860) except that in Vi the user doesn't know there is an error until the macro is
viper.texi(,2861) actually run.  All that means that in order for a definition to be
viper.texi(,2862) successful, the user must do some simple planning of the process in
viper.texi(,2863) advance, to avoid errors.  For instance, if you want to map @kbd{gg} to
viper.texi(,2864) @kbd{llll} in Vi state, you must make sure that there is enough room on the
viper.texi(,2865) current line.  Since @kbd{l} moves the cursor forward, it may signal an
viper.texi(,2866) error on reaching the end of line, which will abort the definition.
viper.texi(,2867) 
viper.texi(,2868) These precautions are necessary only when defining macros; they will help
viper.texi(,2869) avoid the need to redo the job.  When macros are actually run, an error
viper.texi(,2870) during the execution will simply terminate the current execution
viper.texi(,2871) (but the macro will remain mapped).
viper.texi(,2872) 
viper.texi(,2873) A macro name can be a string of characters or a vector of keys.
viper.texi(,2874) The latter makes it possible to define macros bound to, say, double-hits
viper.texi(,2875) on a function key, such as @kbd{up} or @kbd{f13}.
viper.texi(,2876) This is very useful if you run out of function keys on your keyboard; it
viper.texi(,2877) makes Viper macro facility a @emph{keyboard doubler}, so to speak.
viper.texi(,2878) 
viper.texi(,2879) Elsewhere (@xref{Key Bindings}, for details), we review
viper.texi(,2880) the standard Emacs mechanism for binding function keys to commands.
viper.texi(,2881) For instance,
viper.texi(,2882) 
viper.texi(,2883) @example
viper.texi(,2884) (global-set-key [f13] 'repeat-complex-command)
viper.texi(,2885) @end example
viper.texi(,2886) 
viper.texi(,2887) @noindent
viper.texi(,2888) binds the key f13 to the Emacs function that repeats the last minibuffer
viper.texi(,2889) command.  Under Viper, however, you may still use this key for additional
viper.texi(,2890) purposes, if you bind, say, a double-hitting action for that key to some
viper.texi(,2891) other function.  Emacs doesn't allow the user to do that, but Viper does
viper.texi(,2892) this through its keyboard macro facility.  To do this, type @kbd{:map }
viper.texi(,2893) first.  When you are asked to enter a macro name, hit f13 twice, followed by
viper.texi(,2894) @key{RET} or @key{SPC}.
viper.texi(,2895) 
viper.texi(,2896) Emacs will now start the mapping process by actually executing
viper.texi(,2897) Vi and Emacs commands, so that you could see what will happen each time the
viper.texi(,2898) macro is executed.  Suppose now we wanted to bind the key sequence
viper.texi(,2899) @kbd{f13 f13} to the command @code{eval-last-sexp}.  To accomplish this, we
viper.texi(,2900) can type @kbd{M-x eval-last-sexp} followed by @kbd{C-x )}.
viper.texi(,2901) If you answer positively to Viper's offer to save this macro in @file{~/.viper}
viper.texi(,2902) for future uses, the following will be inserted in that file:
viper.texi(,2903) 
viper.texi(,2904) @example
viper.texi(,2905) (viper-record-kbd-macro [f16 f16] 'vi-state
viper.texi(,2906)          [(meta x) e v a l - l a s t - s e x p]
viper.texi(,2907)          'lisp-interaction-mode)
viper.texi(,2908) @end example
viper.texi(,2909) 
viper.texi(,2910) To illustrate the above point, Viper provides two canned macros, which, by
viper.texi(,2911) default, are bound to @kbd{[f12 \1]} and @kbd{[f12 \2]} (invoked by typing
viper.texi(,2912) @kbd{f12} then @kbd{1} and @kbd{2}, respectively).  These macros are useful
viper.texi(,2913) shortcuts to Viper's command ring history.  The first macro will execute the
viper.texi(,2914) second-last destructive command (the last one is executed by @kbd{.}, as
viper.texi(,2915) usual).  The second macro executes the third-last command.
viper.texi(,2916) 
viper.texi(,2917) If you need to go deeper into the command history, you will have to use
viper.texi(,2918) other commands, as described earlier in this section; or you can bind,
viper.texi(,2919) say, @kbd{f12 \3} like this:
viper.texi(,2920) 
viper.texi(,2921) @example
viper.texi(,2922) (viper-record-kbd-macro [f12 \3] 'vi-state
viper.texi(,2923)                       [(meta x) r e p e a t - f r o m - h i s t o r y]
viper.texi(,2924)                       t)
viper.texi(,2925) @end example
viper.texi(,2926) 
viper.texi(,2927) 
viper.texi(,2928) Note that even though the macro uses the function key @kbd{f12}, the key is
viper.texi(,2929) actually free and can still be bound to some Emacs function via
viper.texi(,2930) @code{define-key} or @code{global-set-key}.
viper.texi(,2931) 
viper.texi(,2932) 
viper.texi(,2933) Viper allows the user to define macro names that are prefixes of other macros.
viper.texi(,2934) For instance, one can define @kbd{[[} and @kbd{[[[[} to be macros.
viper.texi(,2935) If you type the exact sequence of such keys and then pause, Viper will
viper.texi(,2936) execute the right macro.  However, if you don't pause and, say, type
viper.texi(,2937) @kbd{[[[[text} then the conflict is resolved as follows.  If only one of the
viper.texi(,2938) key sequences, @kbd{[[} or @kbd{[[[[} has a definition applicable to the
viper.texi(,2939) current buffer, then, in fact, there is no conflict and the right macro
viper.texi(,2940) will be chosen.  If both have applicable definitions, then the first one
viper.texi(,2941) found will be executed.  Usually this is the macro with a shorter name.  So,
viper.texi(,2942) in our case, @kbd{[[[[text} will cause the macro @kbd{[[} to be executed
viper.texi(,2943) twice and then the remaining keys, @kbd{t e x t}, will be processed.
viper.texi(,2944) 
viper.texi(,2945) When defining macros using @kbd{:map} or @kbd{:map!}, the user enters
viper.texi(,2946) the actually keys to be used to invoke the macro.  For instance, you
viper.texi(,2947) should hit the actual key @kbd{f6} if it is to be part of a macro
viper.texi(,2948) name; you do @emph{not} write @kbd{f 6}.  When entering keys, Viper
viper.texi(,2949) displays them as strings or vectors (e.g., @code{"abc"} or @code{[f6
viper.texi(,2950) f7 a]}).  The same holds for unmapping.  Hitting @key{TAB} while
viper.texi(,2951) typing a macro name in the @kbd{:unmap} or @kbd{:unmap!} command will
viper.texi(,2952) cause name completion.  Completions are displayed as strings or
viper.texi(,2953) vectors.  However, as before, you don't actually type @samp{"},
viper.texi(,2954) @samp{[}, or @samp{]} that appear in the completions.  These are
viper.texi(,2955) meta-symbols that indicate whether the corresponding macro name is a
viper.texi(,2956) vector or a string.
viper.texi(,2957) 
viper.texi(,2958) One last difference from Vi: Vi-style keyboard macros cannot be defined in
viper.texi(,2959) terms of other Vi-style keyboard macros (but named Emacs macros are OK).
viper.texi(,2960) More precisely, while defining or executing a macro, the special meaning
viper.texi(,2961) of key sequences (as Vi macros) is ignored.
viper.texi(,2962) This is because it is all too easy to create an infinite loop in this way.
viper.texi(,2963) Since Viper macros are much more powerful than Vi's it is impossible to
viper.texi(,2964) detect such loops.  In practice, this is not really a limitation but,
viper.texi(,2965) rather, a feature.
viper.texi(,2966) 
viper.texi(,2967) We should also note that Vi macros are disabled in the Minibuffer, which
viper.texi(,2968) helps keep some potential troubles away.
viper.texi(,2969) 
viper.texi(,2970) The rate at which the user must type keys in order for them to be
viper.texi(,2971) recognized as a timeout macro is controlled by the variable
viper.texi(,2972) @code{viper-fast-keyseq-timeout}, which defaults to 200 milliseconds.
viper.texi(,2973) 
viper.texi(,2974) For the most part, Viper macros defined in @file{~/.viper} can be shared
viper.texi(,2975) between Emacs, XEmacs, and X and TTY modes.  However, macros defined via
viper.texi(,2976) function keys may need separate definitions when XEmacs and Emacs have
viper.texi(,2977) different names for the same keyboard key.  For instance, the `Page Up' key
viper.texi(,2978) may be known in Emacs as @kbd{prior} and in XEmacs as @kbd{pgup}.
viper.texi(,2979) The problem with TTY may be that the function keys there generate sequences
viper.texi(,2980) of events instead of a single event (as under a window system).
viper.texi(,2981) Emacs maps some of these sequences back to the logical keys
viper.texi(,2982) (e.g., the sequences generated by the arrow keys are mapped to @kbd{up},
viper.texi(,2983) @kbd{left}, etc.).  However, not all function keys are mapped in this way.
viper.texi(,2984) Macros that are bound to key sequences that contain such unmapped function
viper.texi(,2985) keys have to be redefined for TTY's (and possibly for every type of TTY you
viper.texi(,2986) may be using).  To do this, start Emacs on an appropriate TTY device and
viper.texi(,2987) define the macro using @kbd{:map}, as usual.
viper.texi(,2988) 
viper.texi(,2989) @findex @code{viper-describe-kbd-macros}
viper.texi(,2990) Finally, Viper provides a function that conveniently displays all macros
viper.texi(,2991) currently defined.  To see all macros along with their definitions, type
viper.texi(,2992) @kbd{M-x viper-describe-kbd-macros}.
viper.texi(,2993) 
viper.texi(,2994) @node Commands,,Customization,Top
viper.texi(,2995) @chapter Commands
viper.texi(,2996) 
viper.texi(,2997) This section is a semi-automatically bowdlerized version of the Vi
viper.texi(,2998) reference created by @* @samp{maart@@cs.vu.nl} and others.  It can be
viper.texi(,2999) found on the Vi archives.  This reference has been adapted for Viper.@refill
viper.texi(,3000) 
viper.texi(,3001) @menu
viper.texi(,3002) * Groundwork::			Textual Conventions and Viper basics
viper.texi(,3003) * Text Handling::		Moving, Editing, Undoing.
viper.texi(,3004) * Display::			Scrolling.
viper.texi(,3005) * File and Buffer Handling::	Editing, Writing and Quitting.
viper.texi(,3006) * Mapping::			Mapping Keys, Keyboard Macros
viper.texi(,3007) * Shell Commands::		Accessing Shell Commands, Processing Text
viper.texi(,3008) * Options::			Ex options, the @kbd{:set} commands
viper.texi(,3009) * Emacs Related Commands::	Meta Keys, Windows
viper.texi(,3010) * Mouse-bound Commands::        Search and insertion of text
viper.texi(,3011) @end menu
viper.texi(,3012) 
viper.texi(,3013) @node Groundwork, Text Handling, Commands, Commands
viper.texi(,3014) @comment  node-name,  next,  previous,  up
viper.texi(,3015) @section Groundwork
viper.texi(,3016) 
viper.texi(,3017) The VI command set is based on the idea of combining motion commands
viper.texi(,3018) with other commands.  The motion command is used as a text region
viper.texi(,3019) specifier for other commands.
viper.texi(,3020) We classify motion commands into @dfn{point commands} and
viper.texi(,3021) @dfn{line commands}.@refill
viper.texi(,3022) 
viper.texi(,3023) @cindex point commands
viper.texi(,3024) 
viper.texi(,3025) The point commands are:
viper.texi(,3026) 
viper.texi(,3027) @quotation
viper.texi(,3028) @kbd{h}, @kbd{l}, @kbd{0},  @kbd{$}, @kbd{w}, @kbd{W}, @kbd{b}, @kbd{B},
viper.texi(,3029) @kbd{e}, @kbd{E}, @kbd{(}, @kbd{)}, @kbd{/}, @kbd{?}, @kbd{`}, @kbd{f},
viper.texi(,3030) @kbd{F}, @kbd{t}, @kbd{T}, @kbd{%}, @kbd{;}, @kbd{,}, @kbd{^}
viper.texi(,3031) @end quotation
viper.texi(,3032) 
viper.texi(,3033) @cindex line commands
viper.texi(,3034) 
viper.texi(,3035) The line commands are:
viper.texi(,3036) 
viper.texi(,3037) @quotation
viper.texi(,3038) @kbd{j}, @kbd{k}, @kbd{+}, @kbd{-}, @kbd{H}, @kbd{M}, @kbd{L}, @kbd{@{},
viper.texi(,3039) @kbd{@}}, @kbd{G}, @kbd{'},  @kbd{[[}, @kbd{]]}, @kbd{[]}
viper.texi(,3040) @end quotation
viper.texi(,3041) @noindent
viper.texi(,3042) 
viper.texi(,3043) Text Deletion Commands (@pxref{Deleting Text}), Change commands
viper.texi(,3044) (@pxref{Changing Text}), even Shell Commands (@pxref{Shell Commands})
viper.texi(,3045) use these commands to describe a region of text to operate on.
viper.texi(,3046) 
viper.texi(,3047) @cindex r and R region specifiers
viper.texi(,3048) 
viper.texi(,3049) Viper adds two region descriptors, @kbd{r} and @kbd{R}.  These describe
viper.texi(,3050) the Emacs regions (@pxref{Basics}), but they are not movement commands.
viper.texi(,3051) 
viper.texi(,3052) The command description uses angle brackets @samp{<>} to indicate
viper.texi(,3053) metasyntactic variables, since the normal conventions of using simple
viper.texi(,3054) text can be confusing with Viper where the commands themselves are
viper.texi(,3055) characters.  Watch out where @kbd{<} shift commands and @kbd{<count>} are
viper.texi(,3056) mentioned together!!!
viper.texi(,3057) 
viper.texi(,3058) @kindex <move>
viper.texi(,3059) @kindex <a-z>
viper.texi(,3060) @kindex <address>
viper.texi(,3061) @cindex <move>
viper.texi(,3062) @cindex <a-z>
viper.texi(,3063) @cindex <address>
viper.texi(,3064) @cindex movements
viper.texi(,3065) 
viper.texi(,3066) @samp{<move>} refers to the above movement commands, and @samp{<a-z>}
viper.texi(,3067) refers to registers or textmarkers from @samp{a} to @samp{z}.  Note
viper.texi(,3068) that the @samp{<move>}  is described by full move commands, that is to
viper.texi(,3069) say they will take counts, and otherwise behave like normal move commands.
viper.texi(,3070) @cindex Ex addresses
viper.texi(,3071) @samp{<address>} refers to Ex line addresses, which include
viper.texi(,3072) 
viper.texi(,3073) @table @kbd
viper.texi(,3074) @item .@: <No address>
viper.texi(,3075) Current line
viper.texi(,3076) @item .+n .-n
viper.texi(,3077) Add or subtract for current line
viper.texi(,3078) @item number
viper.texi(,3079) Actual line number, use @kbd{.=} to get the line number
viper.texi(,3080) @item '<a-z>
viper.texi(,3081) Textmarker
viper.texi(,3082) @item $
viper.texi(,3083) Last line
viper.texi(,3084) @item x,y
viper.texi(,3085) Where x and y are one of the above
viper.texi(,3086) @item %
viper.texi(,3087) @cindex % (Ex address)
viper.texi(,3088) For the whole file, same as (1,$).
viper.texi(,3089) @item /<pat>/
viper.texi(,3090) @itemx ?<pat>?
viper.texi(,3091) Next or previous line with pattern <pat>.
viper.texi(,3092) 
viper.texi(,3093) Note that the pattern is allowed to contain newline character (inserted as
viper.texi(,3094) @kbd{C-qC-j}).  Therefore, one can search for patterns that span several
viper.texi(,3095) lines.
viper.texi(,3096) @end table
viper.texi(,3097) 
viper.texi(,3098) @cindex % (Current file)
viper.texi(,3099) Note that @samp{%} is used in Ex commands @kbd{:e} and @kbd{:r <shell-cmd>}
viper.texi(,3100) to mean current file.  If you want a @samp{%} in your command, it must be
viper.texi(,3101) escaped as @samp{\%}. Note that @kbd{:w} and the regular @kbd{:r <file>}
viper.texi(,3102) command doesn't support the meta symbols @samp{%} and @samp{#}, because
viper.texi(,3103) file history is a better mechanism.
viper.texi(,3104) @cindex # (Previous file)
viper.texi(,3105) Similarly, @samp{#} expands to the previous file.  The previous file is
viper.texi(,3106) the first file in @kbd{:args} listing.  This defaults to previous window
viper.texi(,3107) in the VI sense if you have one window only.
viper.texi(,3108) 
viper.texi(,3109) @kindex <args>
viper.texi(,3110) @kindex <cmd>
viper.texi(,3111) @cindex <args>
viper.texi(,3112) @cindex <cmd>
viper.texi(,3113) @noindent
viper.texi(,3114) Others like @samp{<args> -- arguments}, @samp{<cmd> -- command} etc.
viper.texi(,3115) should be fairly obvious.
viper.texi(,3116) 
viper.texi(,3117) @noindent
viper.texi(,3118) Common characters referred to include:
viper.texi(,3119) 
viper.texi(,3120) @table @kbd
viper.texi(,3121) @item <sp>
viper.texi(,3122) Space
viper.texi(,3123) @item <ht>
viper.texi(,3124) Tab
viper.texi(,3125) @item <lf>
viper.texi(,3126) Linefeed
viper.texi(,3127) @item <esc>
viper.texi(,3128) Escape
viper.texi(,3129) @item <cr>
viper.texi(,3130) Return, Enter
viper.texi(,3131) @end table
viper.texi(,3132) @cindex <cr>
viper.texi(,3133) @cindex <esc>
viper.texi(,3134) @cindex <lf>
viper.texi(,3135) @cindex <ht>
viper.texi(,3136) @cindex <sp>
viper.texi(,3137) 
viper.texi(,3138) @cindex words
viper.texi(,3139) @cindex WORDS
viper.texi(,3140) @cindex char
viper.texi(,3141) @cindex CHAR
viper.texi(,3142) 
viper.texi(,3143) We also use @samp{word} for alphanumeric/non-alphanumeric words, and
viper.texi(,3144) @samp{WORD} for whitespace delimited words.  @samp{char} refers to any
viper.texi(,3145) ASCII character, @samp{CHAR} to non-whitespace character.
viper.texi(,3146) Brackets @samp{[]} indicate optional parameters; @samp{<count>} also
viper.texi(,3147) optional, usually defaulting to 1.  Brackets are elided for
viper.texi(,3148) @samp{<count>} to eschew obfuscation.
viper.texi(,3149) 
viper.texi(,3150) Viper's idea of Vi's words is slightly different from Vi.  First, Viper
viper.texi(,3151) words understand Emacs symbol tables.  Therefore, all symbols declared to be
viper.texi(,3152) alphanumeric in a symbol table can automatically be made part of the Viper
viper.texi(,3153) word.  This is useful when, for instance, editing text containing European,
viper.texi(,3154) Cyrillic, Japanese, etc., texts.
viper.texi(,3155) 
viper.texi(,3156) Second, Viper lets you depart from Vi's idea of a word by changing the a
viper.texi(,3157) syntax preference via the customization widget (the variable
viper.texi(,3158) @code{viper-syntax-preference}) or by executing
viper.texi(,3159) @code{viper-set-syntax-preference} interactively.
viper.texi(,3160) 
viper.texi(,3161) By default, Viper syntax preference is @code{reformed-vi}, which means that
viper.texi(,3162) Viper considers only those symbols to be part of a word that are specified
viper.texi(,3163) as word-symbols by the current Emacs syntax table (which may be different
viper.texi(,3164) for different major modes) plus the underscore symbol @kbd{_}, minus the
viper.texi(,3165) symbols that are not considered words in Vi (e.g., `,',;, etc.), but may be
viper.texi(,3166) considered as word-symbols by various Emacs major modes.  Reformed-Vi works
viper.texi(,3167) very close to Vi, and it also recognizes words in other
viper.texi(,3168) alphabets.  Therefore, this is the most appropriate mode for editing text
viper.texi(,3169) and is likely to fit all your needs.
viper.texi(,3170) 
viper.texi(,3171) You can also set Viper syntax preference to @code{strict-vi}, which would
viper.texi(,3172) cause Viper to view all non-English letters as non-word-symbols.
viper.texi(,3173) 
viper.texi(,3174) You can also specify @code{emacs} as your preference, which would
viper.texi(,3175) make Viper use exactly the same notion of a word as Emacs does.  In
viper.texi(,3176) particular, the underscore may not be part of a word in some major modes.
viper.texi(,3177) 
viper.texi(,3178) Finally, if @code{viper-syntax-preference} is set to @code{extended}, Viper
viper.texi(,3179) words would consist of characters that are classified as alphanumeric
viper.texi(,3180) @emph{or} as parts of symbols.  This is convenient for editing programs.
viper.texi(,3181) 
viper.texi(,3182) @code{viper-syntax-preference} is a local variable, so it can have different
viper.texi(,3183) values for different major modes.  For instance, in programming modes it can
viper.texi(,3184) have the value @code{extended}.  In text modes where words contain special
viper.texi(,3185) characters, such as European (non-English) letters, Cyrillic letters, etc.,
viper.texi(,3186) the value can be @code{reformed-vi} or @code{emacs}.
viper.texi(,3187) If you consider using different syntactic preferences for different major
viper.texi(,3188) modes, you should execute, for example,
viper.texi(,3189) 
viper.texi(,3190) @example
viper.texi(,3191) (viper-set-syntax-preference nil "extended")
viper.texi(,3192) @end example
viper.texi(,3193) 
viper.texi(,3194) in the appropriate major mode hooks.
viper.texi(,3195) 
viper.texi(,3196) @vindex @code{viper-syntax-preference}
viper.texi(,3197) @findex @code{viper-set-syntax-preference}
viper.texi(,3198) @cindex syntax table
viper.texi(,3199) 
viper.texi(,3200) 
viper.texi(,3201) 
viper.texi(,3202) The above discussion concerns only the movement commands.  In regular
viper.texi(,3203) expressions, words remain the same as in Emacs.  That is, the expressions
viper.texi(,3204) @code{\w}, @code{\>}, @code{\<}, etc., use Emacs' idea of what is a word,
viper.texi(,3205) and they don't look into the value of variable
viper.texi(,3206) @code{viper-syntax-preference}.  This is because Viper avoids changing
viper.texi(,3207) syntax tables in order to not thwart the various major modes that set these
viper.texi(,3208) tables.
viper.texi(,3209) 
viper.texi(,3210) The usual Emacs convention is used to indicate Control Characters, i.e
viper.texi(,3211) C-h for Control-h.  @emph{Do not confuse this with a sequence of separate
viper.texi(,3212) characters
viper.texi(,3213) C, -, h!!!} The @kbd{^} is itself, never used to indicate a
viper.texi(,3214) Control character.
viper.texi(,3215) 
viper.texi(,3216) Finally, we note that Viper's Ex-style commands can be made to work on the
viper.texi(,3217) current Emacs region.  This is done by typing a digit argument before
viper.texi(,3218) @kbd{:}.  For instance, typing @kbd{1:} will propmt you with something like
viper.texi(,3219) @emph{:123,135}, assuming that the current region starts at line 123 and
viper.texi(,3220) ends at line 135.  There is no need to type the line numbers, since Viper
viper.texi(,3221) inserts them automatically in front of the Ex command.
viper.texi(,3222) @cindex Ex commands
viper.texi(,3223) 
viper.texi(,3224) @node Text Handling, Display, Groundwork, Commands
viper.texi(,3225) @section Text Handling
viper.texi(,3226) 
viper.texi(,3227) @menu
viper.texi(,3228) * Move Commands::		Moving, Searching
viper.texi(,3229) * Marking::		        Textmarkers in Viper and the Emacs Mark.
viper.texi(,3230) * Appending Text::		Text insertion, Shifting, Putting
viper.texi(,3231) * Editing in Insert State::	Autoindent, Quoting etc.
viper.texi(,3232) * Deleting Text::		Deleting
viper.texi(,3233) * Changing Text::		Changing, Replacement, Joining
viper.texi(,3234) * Search and Replace::		Searches, Query Replace, Pattern Commands
viper.texi(,3235) * Yanking::			Yanking, Viewing Registers
viper.texi(,3236) * Undoing::			Multiple Undo, Backups
viper.texi(,3237) @end menu
viper.texi(,3238) 
viper.texi(,3239) @node Move Commands,Marking,,Text Handling
viper.texi(,3240) @subsection Move Commands
viper.texi(,3241) 
viper.texi(,3242) @cindex movement commands
viper.texi(,3243) @cindex searching
viper.texi(,3244) @cindex textmarkers
viper.texi(,3245) @cindex markers
viper.texi(,3246) @cindex column movement
viper.texi(,3247) @cindex paragraphs
viper.texi(,3248) @cindex headings
viper.texi(,3249) @cindex sections
viper.texi(,3250) @cindex sentences
viper.texi(,3251) @cindex matching parens
viper.texi(,3252) @cindex paren matching
viper.texi(,3253) 
viper.texi(,3254) @table @kbd
viper.texi(,3255) @item <count>  h  C-h
viper.texi(,3256) <count> chars to the left.
viper.texi(,3257) @item <count>  j  <lf> C-n
viper.texi(,3258) <count> lines downward.
viper.texi(,3259) @item <count>  l  <sp>
viper.texi(,3260) <count> chars to the right.
viper.texi(,3261) @item <count>  k  C-p
viper.texi(,3262) <count> lines upward.
viper.texi(,3263) @item <count>  $
viper.texi(,3264) To the end of line <count> from the cursor.
viper.texi(,3265) @item <count>  ^
viper.texi(,3266) To the first CHAR <count> - 1 lines lower.
viper.texi(,3267) @item <count>  -
viper.texi(,3268) To the first CHAR <count> lines higher.
viper.texi(,3269) @item <count>  +  <cr>
viper.texi(,3270) To the first CHAR <count> lines lower.
viper.texi(,3271) @item  0
viper.texi(,3272) To the first char of the line.
viper.texi(,3273) @item <count> |
viper.texi(,3274) To column <count>
viper.texi(,3275) @item <count>  f<char>
viper.texi(,3276) <count> <char>s to the right (find).
viper.texi(,3277) @item <count>  t<char>
viper.texi(,3278) Till before <count> <char>s to the right.
viper.texi(,3279) @item <count>  F<char>
viper.texi(,3280) <count> <char>s to the left.
viper.texi(,3281) @item <count>  T<char>
viper.texi(,3282) Till after <count> <char>s to the left.
viper.texi(,3283) @item <count>  ;
viper.texi(,3284) Repeat latest @kbd{f t F T} <count> times.
viper.texi(,3285) @item <count>  ,
viper.texi(,3286) Repeat latest @kbd{f t F T}
viper.texi(,3287) <count> times in opposite direction.
viper.texi(,3288) @item <count>  w
viper.texi(,3289) <count> words forward.
viper.texi(,3290) @item <count>  W
viper.texi(,3291) <count> WORDS forward.
viper.texi(,3292) @item <count>  b
viper.texi(,3293) <count> words backward.
viper.texi(,3294) @item <count>  B
viper.texi(,3295) <count> WORDS backward.
viper.texi(,3296) @item <count>  e
viper.texi(,3297) To the end of word <count> forward.
viper.texi(,3298) @item <count>  E
viper.texi(,3299) To the end of WORD <count> forward.
viper.texi(,3300) @item <count>  G
viper.texi(,3301) Go to line <count> (default end-of-file).
viper.texi(,3302) @item <count>  H
viper.texi(,3303) To line <count> from top of the screen (home).
viper.texi(,3304) @item <count>  L
viper.texi(,3305) To line <count> from bottom of the screen (last).
viper.texi(,3306) @item  M
viper.texi(,3307) To the middle line of the screen.
viper.texi(,3308) @item <count>  )
viper.texi(,3309) <count> sentences forward.
viper.texi(,3310) @item <count>  (
viper.texi(,3311) <count> sentences backward.
viper.texi(,3312) @item <count>  @}
viper.texi(,3313) <count> paragraphs forward.
viper.texi(,3314) @item <count>  @{
viper.texi(,3315) <count> paragraphs backward.
viper.texi(,3316) @item <count>  ]]
viper.texi(,3317) To the <count>th heading.
viper.texi(,3318) @item <count>  [[
viper.texi(,3319) To the <count>th previous heading.
viper.texi(,3320) @item <count>  []
viper.texi(,3321) To the end of <count>th heading.
viper.texi(,3322) @item  m<a-z>
viper.texi(,3323) Mark the cursor position with a letter.
viper.texi(,3324) @item  `<a-z>
viper.texi(,3325) To the mark.
viper.texi(,3326) @item  '<a-z>
viper.texi(,3327) To the first CHAR of the line with the mark.
viper.texi(,3328) @item [<a-z>
viper.texi(,3329) Show contents of textmarker.
viper.texi(,3330) @item ]<a-z>
viper.texi(,3331) Show contents of register.
viper.texi(,3332) @item  ``
viper.texi(,3333) To the cursor position before the latest absolute
viper.texi(,3334) jump (of which are examples @kbd{/} and @kbd{G}).
viper.texi(,3335) @item  ''
viper.texi(,3336) To the first CHAR of the line on which the cursor
viper.texi(,3337) was placed before the latest absolute jump.
viper.texi(,3338) @item <count>  /<string>
viper.texi(,3339) To the <count>th occurrence of <string>.
viper.texi(,3340) @item <count>  /<cr>
viper.texi(,3341) To the <count>th occurrence of <string> from previous @kbd{/ or ?}.
viper.texi(,3342) @item <count>  ?<string>
viper.texi(,3343) To the <count>th previous occurrence of <string>.
viper.texi(,3344) @item <count>  ?<cr>
viper.texi(,3345) To the <count>th previous occurrence of <string> from previous @kbd{?@: or /}.
viper.texi(,3346) @item  n
viper.texi(,3347) Repeat latest @kbd{/} @kbd{?} (next).
viper.texi(,3348) @item  N
viper.texi(,3349) Repeat latest search in opposite direction.
viper.texi(,3350) @item C-c /
viper.texi(,3351) Without a prefix argument, this command toggles
viper.texi(,3352) case-sensitive/case-insensitive search modes and plain vanilla/regular
viper.texi(,3353) expression search.  With the prefix argument 1, i.e.,
viper.texi(,3354) @kbd{1 C-c /}, this toggles case-sensitivity; with the prefix argument 2,
viper.texi(,3355) toggles plain vanilla search and search using
viper.texi(,3356) regular expressions.  @xref{Viper Specials}, for alternative ways to invoke
viper.texi(,3357) this function.
viper.texi(,3358) @cindex vanilla search
viper.texi(,3359) @cindex case-sensitive search
viper.texi(,3360) @cindex case-insensitive search
viper.texi(,3361) @item  %
viper.texi(,3362) Find the next bracket/parenthesis/brace and go to its match.
viper.texi(,3363) By default, Viper ignores brackets/parentheses/braces that occur inside
viper.texi(,3364) parentheses.  You can change this by setting
viper.texi(,3365) @code{viper-parse-sexp-ignore-comments} to nil in your @file{.viper} file.
viper.texi(,3366) This option can also be toggled interactively if you quickly hit @kbd{%%%}.
viper.texi(,3367) 
viper.texi(,3368) This latter feature is implemented as a vi-style keyboard macro.  If you
viper.texi(,3369) don't want this macro, put
viper.texi(,3370) 
viper.texi(,3371) @example
viper.texi(,3372) (viper-set-parsing-style-toggling-macro 'undefine)
viper.texi(,3373) @end example
viper.texi(,3374) @findex @code{viper-set-parsing-style-toggling-macro}
viper.texi(,3375) 
viper.texi(,3376) in your @file{~/.viper} file.
viper.texi(,3377) 
viper.texi(,3378) @end table
viper.texi(,3379) @kindex @kbd{%}
viper.texi(,3380) @kindex @kbd{C-c /}
viper.texi(,3381) @kindex @kbd{N}
viper.texi(,3382) @kindex @kbd{n}
viper.texi(,3383) @kindex @kbd{?<cr>}
viper.texi(,3384) @kindex @kbd{/<cr>}
viper.texi(,3385) @kindex @kbd{?<string>}
viper.texi(,3386) @kindex @kbd{/<string>}
viper.texi(,3387) @kindex @kbd{''}
viper.texi(,3388) @kindex @kbd{``}
viper.texi(,3389) @kindex @kbd{]<a-z>}
viper.texi(,3390) @kindex @kbd{[<a-z>}
viper.texi(,3391) @kindex @kbd{'<a-z>}
viper.texi(,3392) @kindex @kbd{`<a-z>}
viper.texi(,3393) @kindex @kbd{m<a-z>}
viper.texi(,3394) @kindex @kbd{[]}
viper.texi(,3395) @kindex @kbd{[[}
viper.texi(,3396) @kindex @kbd{]]}
viper.texi(,3397) @kindex @kbd{@{}
viper.texi(,3398) @kindex @kbd{@}}
viper.texi(,3399) @kindex @kbd{(}
viper.texi(,3400) @kindex @kbd{)}
viper.texi(,3401) @kindex @kbd{M}
viper.texi(,3402) @kindex @kbd{L}
viper.texi(,3403) @kindex @kbd{H}
viper.texi(,3404) @kindex @kbd{G}
viper.texi(,3405) @kindex @kbd{E}
viper.texi(,3406) @kindex @kbd{e}
viper.texi(,3407) @kindex @kbd{B}
viper.texi(,3408) @kindex @kbd{b}
viper.texi(,3409) @kindex @kbd{W}
viper.texi(,3410) @kindex @kbd{w}
viper.texi(,3411) @kindex @kbd{,}
viper.texi(,3412) @kindex @kbd{;}
viper.texi(,3413) @kindex @kbd{T<char>}
viper.texi(,3414) @kindex @kbd{F<char>}
viper.texi(,3415) @kindex @kbd{t<char>}
viper.texi(,3416) @kindex @kbd{f<char>}
viper.texi(,3417) @kindex @kbd{|}
viper.texi(,3418) @kindex @kbd{0}
viper.texi(,3419) @kindex @kbd{<cr>}
viper.texi(,3420) @kindex @kbd{+}
viper.texi(,3421) @kindex @kbd{-}
viper.texi(,3422) @kindex @kbd{^}
viper.texi(,3423) @kindex @kbd{$}
viper.texi(,3424) @kindex @kbd{C-p}
viper.texi(,3425) @kindex @kbd{<lf>}
viper.texi(,3426) @kindex @kbd{<sp>}
viper.texi(,3427) @kindex @kbd{C-n}
viper.texi(,3428) @kindex @kbd{C-h}
viper.texi(,3429) @kindex @kbd{h}
viper.texi(,3430) @kindex @kbd{j}
viper.texi(,3431) @kindex @kbd{k}
viper.texi(,3432) @kindex @kbd{l}
viper.texi(,3433) @vindex @code{viper-parse-sexp-ignore-comments}
viper.texi(,3434) 
viper.texi(,3435) @node Marking,Appending Text,Move Commands,Text Handling
viper.texi(,3436) @subsection Marking
viper.texi(,3437) 
viper.texi(,3438) Emacs mark is referred to in the region specifiers @kbd{r} and @kbd{R}.
viper.texi(,3439) @xref{Emacs Preliminaries}, and @xref{Basics}, for explanation.  Also
viper.texi(,3440) see @ref{Mark,,Mark,emacs,The GNU Emacs manual}, for an explanation of
viper.texi(,3441) the Emacs mark ring.
viper.texi(,3442) 
viper.texi(,3443) @cindex marking
viper.texi(,3444) 
viper.texi(,3445) @table @kbd
viper.texi(,3446) @item m<a-z>
viper.texi(,3447) Mark the current file and position with the specified letter.
viper.texi(,3448) @item m .
viper.texi(,3449) Set the Emacs mark (@pxref{Emacs Preliminaries}) at point.
viper.texi(,3450) @item m ^
viper.texi(,3451) Set the Emacs mark (@pxref{Emacs Preliminaries}) back to where it was last
viper.texi(,3452) set with the @kbd{m.} command. This is useful when you set the mark with
viper.texi(,3453) @kbd{m.}, but then some other command (such as @kbd{L} or @kbd{G}) changes
viper.texi(,3454) it in a way that you didn't like.
viper.texi(,3455) @item m <
viper.texi(,3456) Set the Emacs mark at beginning of buffer.
viper.texi(,3457) @item m >
viper.texi(,3458) Set the Emacs mark at end of buffer.
viper.texi(,3459) @item m ,
viper.texi(,3460) Jump to the Emacs mark.
viper.texi(,3461) @item :mark <char>
viper.texi(,3462) Mark position with text marker named <char>.  This is an Ex command.
viper.texi(,3463) @item :k <char>
viper.texi(,3464) Same as @kbd{:mark}.
viper.texi(,3465) @item ``
viper.texi(,3466) Exchange point and mark.
viper.texi(,3467) @item ''
viper.texi(,3468) Exchange point and mark and go to the first CHAR on line.
viper.texi(,3469) @item '<a-z>
viper.texi(,3470) Go to specified Viper mark.
viper.texi(,3471) @item
viper.texi(,3472) Go to specified Viper mark and go to the first CHAR on line.
viper.texi(,3473) @end table
viper.texi(,3474) @kindex @kbd{m<a-z>}
viper.texi(,3475) @kindex @kbd{m.}
viper.texi(,3476) @kindex @kbd{m>}
viper.texi(,3477) @kindex @kbd{m<}
viper.texi(,3478) @kindex @kbd{m,}
viper.texi(,3479) @kindex @kbd{m^}
viper.texi(,3480) @findex @kbd{:mark}
viper.texi(,3481) @findex @kbd{:k}
viper.texi(,3482) @kindex @kbd{''}
viper.texi(,3483) @kindex @kbd{``}
viper.texi(,3484) @kindex @kbd{`<a-z>}
viper.texi(,3485) @kindex @kbd{'<a-z>}
viper.texi(,3486) 
viper.texi(,3487) @node  Appending Text, Editing in Insert State, Marking,Text Handling
viper.texi(,3488) @subsection Appending Text
viper.texi(,3489) 
viper.texi(,3490) @xref{Options}, to see how to change tab and shiftwidth size.  See the GNU
viper.texi(,3491) Emacs manual, or try @kbd{C-ha tabs} (If you have turned Emacs help on).
viper.texi(,3492) Check out the variable @code{indent-tabs-mode} to put in just spaces.
viper.texi(,3493) Also see options for word-wrap.
viper.texi(,3494) 
viper.texi(,3495) @cindex inserting
viper.texi(,3496) @cindex appending
viper.texi(,3497) @cindex paste
viper.texi(,3498) @cindex put
viper.texi(,3499) 
viper.texi(,3500) @table @kbd
viper.texi(,3501) @item <count>  a
viper.texi(,3502) <count> times after the cursor.
viper.texi(,3503) @item <count>  A
viper.texi(,3504) <count> times at the end of line.
viper.texi(,3505) @item <count>  i
viper.texi(,3506) <count> times before the cursor (insert).
viper.texi(,3507) @item <count>  I
viper.texi(,3508) <count> times before the first CHAR of the line
viper.texi(,3509) @item <count>  o
viper.texi(,3510) On a new line below the current (open).
viper.texi(,3511) The count is only useful on a slow terminal.
viper.texi(,3512) @item <count>  O
viper.texi(,3513) On a new line above the current.
viper.texi(,3514) The count is only useful on a slow terminal.
viper.texi(,3515) @item <count>  ><move>
viper.texi(,3516) Shift the lines described by <count><move> one
viper.texi(,3517) shiftwidth to the right (layout!).
viper.texi(,3518) @item <count>  >>
viper.texi(,3519) Shift <count> lines one shiftwidth to the right.
viper.texi(,3520) @item <count>  ["<a-z1-9>]p
viper.texi(,3521) Put the contents of the (default undo) buffer
viper.texi(,3522) <count> times after the cursor.  The register will
viper.texi(,3523) be automatically down-cased.
viper.texi(,3524) @item <count>  ["<a-z1-9>]P
viper.texi(,3525) Put the contents of the (default undo) buffer
viper.texi(,3526) <count> times before the cursor.  The register will
viper.texi(,3527) @item [<a-z>
viper.texi(,3528) Show contents of textmarker.
viper.texi(,3529) @item ]<a-z>
viper.texi(,3530) Show contents of register.
viper.texi(,3531) @item <count>  .
viper.texi(,3532) Repeat previous command <count> times.  For destructive
viper.texi(,3533) commands as well as undo.
viper.texi(,3534) @item f1 1 and f1 2
viper.texi(,3535) While @kbd{.} repeats the last destructive command,
viper.texi(,3536) these two macros repeat the second-last and the third-last destructive
viper.texi(,3537) commands.  @xref{Vi Macros}, for more information on Vi macros.
viper.texi(,3538) @item C-c M-p and C-c M-n
viper.texi(,3539) In Vi state,
viper.texi(,3540) these commands help peruse the history of Vi's destructive commands.
viper.texi(,3541) Successive typing of @kbd{C-c M-p} causes Viper to search the history in
viper.texi(,3542) the direction
viper.texi(,3543) of older commands, while hitting @kbd{C-c M-n} does so in reverse
viper.texi(,3544) order.  Each command in the history is displayed in the Minibuffer.  The
viper.texi(,3545) displayed command can
viper.texi(,3546) then be executed by typing `@kbd{.}'.
viper.texi(,3547) 
viper.texi(,3548) Since typing the above sequences of keys may be tedious, the
viper.texi(,3549) functions doing the perusing can be bound to unused keyboard keys in the
viper.texi(,3550) @file{~/.viper} file.  @xref{Viper Specials}, for details.
viper.texi(,3551) @end table
viper.texi(,3552) @kindex @kbd{C-c M-p}
viper.texi(,3553) @kindex @kbd{C-c M-n}
viper.texi(,3554) @kindex @kbd{.}
viper.texi(,3555) @kindex @kbd{]<a-z>}
viper.texi(,3556) @kindex @kbd{[<a-z>}
viper.texi(,3557) @kindex @kbd{P}
viper.texi(,3558) @kindex @kbd{p}
viper.texi(,3559) @kindex @kbd{"<a-z1-9>p}
viper.texi(,3560) @kindex @kbd{"<a-z1-9>P}
viper.texi(,3561) @kindex @kbd{>>}
viper.texi(,3562) @kindex @kbd{><move>}
viper.texi(,3563) @kindex @kbd{O}
viper.texi(,3564) @kindex @kbd{o}
viper.texi(,3565) @kindex @kbd{i}
viper.texi(,3566) @kindex @kbd{A}
viper.texi(,3567) @kindex @kbd{a}
viper.texi(,3568) 
viper.texi(,3569) @node Editing in Insert State, Deleting Text, Appending Text,Text Handling
viper.texi(,3570) @subsection Editing in Insert State
viper.texi(,3571) 
viper.texi(,3572) Minibuffer can be edited similarly to Insert state, and you can switch
viper.texi(,3573) between Insert/Replace/Vi states at will.
viper.texi(,3574) Some users prefer plain Emacs feel in the Minibuffer.  To this end, set
viper.texi(,3575) @var{viper-vi-style-in-minibuffer} to @code{nil}.
viper.texi(,3576) 
viper.texi(,3577) @cindex Insert state
viper.texi(,3578) 
viper.texi(,3579) @table @kbd
viper.texi(,3580) @item C-v
viper.texi(,3581) Deprive the next char of its special meaning (quoting).
viper.texi(,3582) @item C-h
viper.texi(,3583) One char back.
viper.texi(,3584) @item C-w
viper.texi(,3585) One word back.
viper.texi(,3586) @item C-u
viper.texi(,3587) Back to the begin of the change on the
viper.texi(,3588) current line.
viper.texi(,3589) 
viper.texi(,3590) @end table
viper.texi(,3591) @kindex @kbd{C-u}
viper.texi(,3592) @kindex @kbd{C-w}
viper.texi(,3593) @kindex @kbd{C-v}
viper.texi(,3594) 
viper.texi(,3595) @node Deleting Text, Changing Text, Editing in Insert State, Text Handling
viper.texi(,3596) @subsection Deleting Text
viper.texi(,3597) 
viper.texi(,3598) 
viper.texi(,3599) There is one difference in text deletion that you should be
viper.texi(,3600) aware of.  This difference comes from Emacs and was adopted in Viper
viper.texi(,3601) because we find it very useful.  In Vi, if you delete a line, say, and then
viper.texi(,3602) another line, these two deletions are separated and are put back
viper.texi(,3603) separately if you use the @samp{p} command.  In Emacs (and Viper), successive
viper.texi(,3604) series of deletions that are @emph{not interrupted} by other commands are
viper.texi(,3605) lumped together, so the deleted text gets accumulated and can be put back
viper.texi(,3606) as one chunk.  If you want to break a sequence of deletions so that the
viper.texi(,3607) newly deleted text could be put back separately from the previously deleted
viper.texi(,3608) text, you should perform a non-deleting action, e.g., move the cursor one
viper.texi(,3609) character in any direction.
viper.texi(,3610) 
viper.texi(,3611) @cindex shifting text
viper.texi(,3612) 
viper.texi(,3613) @table @kbd
viper.texi(,3614) @item <count>  x
viper.texi(,3615) Delete <count> chars under and after the cursor.
viper.texi(,3616) @item <count>  X
viper.texi(,3617) Delete <count> chars before the cursor.
viper.texi(,3618) @item <count>  d<move>
viper.texi(,3619) Delete from point to endpoint of <count><move>.
viper.texi(,3620) @item <count>  dd
viper.texi(,3621) Delete <count> lines.
viper.texi(,3622) @item  D
viper.texi(,3623) The rest of the line.
viper.texi(,3624) @item <count>  <<move>
viper.texi(,3625) Shift the lines described by <count><move> one
viper.texi(,3626) shiftwidth to the left (layout!).
viper.texi(,3627) @item <count>  <<
viper.texi(,3628) Shift <count> lines one shiftwidth to the left.
viper.texi(,3629) @end table
viper.texi(,3630) @kindex @kbd{<<}
viper.texi(,3631) @kindex @kbd{<<move>}
viper.texi(,3632) @kindex @kbd{D}
viper.texi(,3633) @kindex @kbd{dd}
viper.texi(,3634) @kindex @kbd{d<move>}
viper.texi(,3635) @kindex @kbd{X}
viper.texi(,3636) @kindex @kbd{x}
viper.texi(,3637) 
viper.texi(,3638) @node Changing Text, Search and Replace, Deleting Text,Text Handling
viper.texi(,3639) @subsection Changing Text
viper.texi(,3640) 
viper.texi(,3641) @cindex joining lines
viper.texi(,3642) @cindex changing case
viper.texi(,3643) @cindex quoting regions
viper.texi(,3644) @cindex substitution
viper.texi(,3645) 
viper.texi(,3646) @table @kbd
viper.texi(,3647) @item <count>  r<char>
viper.texi(,3648) Replace <count> chars by <char> - no <esc>.
viper.texi(,3649) @item <count>  R
viper.texi(,3650) Overwrite the rest of the line,
viper.texi(,3651) appending change @var{count - 1} times.
viper.texi(,3652) @item <count>  s
viper.texi(,3653) Substitute <count> chars.
viper.texi(,3654) @item <count>  S
viper.texi(,3655) Change <count> lines.
viper.texi(,3656) @item <count>  c<move>
viper.texi(,3657) Change from begin to endpoint of <count><move>.
viper.texi(,3658) @item <count>  cc
viper.texi(,3659) Change <count> lines.
viper.texi(,3660) @item <count>  C
viper.texi(,3661) The rest of the line and <count> - 1 next lines.
viper.texi(,3662) @item <count>  =<move>
viper.texi(,3663) Reindent the region described by move.
viper.texi(,3664) @item <count>  ~
viper.texi(,3665) Switch lower and upper cases.
viper.texi(,3666) @item <count>  J
viper.texi(,3667) Join <count> lines (default 2).
viper.texi(,3668) @item  :[x,y]s/<pat>/<repl>/<f>
viper.texi(,3669) Substitute (on lines x through y) the pattern
viper.texi(,3670) <pat> (default the last pattern) with <repl>.  Useful
viper.texi(,3671) flags <f> are @samp{g} for @samp{global} (i.e.@: change every
viper.texi(,3672) non-overlapping occurrence of <pat>) and @samp{c} for
viper.texi(,3673) @samp{confirm} (type @samp{y} to confirm a particular
viper.texi(,3674) substitution, else @samp{n} ).  Instead of @kbd{/} any
viper.texi(,3675) punctuation CHAR unequal to <space> <tab> and <lf> can be used as
viper.texi(,3676) delimiter.
viper.texi(,3677) 
viper.texi(,3678) In Emacs, @samp{\&} stands for the last matched expression, so
viper.texi(,3679) @kbd{s/[ab]+/\&\&/} will double the string matched by @kbd{[ab]}.
viper.texi(,3680) Viper doesn't treat @samp{&} specially, unlike Vi: use @samp{\&} instead.
viper.texi(,3681) 
viper.texi(,3682) Viper does not parse search patterns and does not expand special symbols
viper.texi(,3683) found there (e.g., @samp{~} is not expanded to the result of the previous
viper.texi(,3684) substitution).
viper.texi(,3685) 
viper.texi(,3686) Note: @emph{The newline character (inserted as @kbd{C-qC-j})
viper.texi(,3687) can be used in <repl>}.
viper.texi(,3688) @item  :[x,y]copy [z]
viper.texi(,3689) Copy text between @kbd{x} and @kbd{y} to the position after @kbd{z}.
viper.texi(,3690) @item  :[x,y]t [z]
viper.texi(,3691) Same as @kbd{:copy}.
viper.texi(,3692) @item  :[x,y]move [z]
viper.texi(,3693) Move text between @kbd{x} and @kbd{y} to the position after @kbd{z}.
viper.texi(,3694) @item  &
viper.texi(,3695) Repeat latest Ex substitute command, e.g.
viper.texi(,3696) @kbd{:s/wrong/right}.
viper.texi(,3697) @item :x,yp
viper.texi(,3698) @itemx :g/Pat/p
viper.texi(,3699) @itemx :v/Pat/p
viper.texi(,3700) The above commands display certain buffer lines in a
viper.texi(,3701) temporary buffer. The first form above displays the buffer lines between
viper.texi(,3702) @kbd{x} and @kbd{y}. The second displays the lines of the buffer, which
viper.texi(,3703) match a given pattern. The third form displays the lines that do @emph{not}
viper.texi(,3704) match the given pattern.
viper.texi(,3705) @item #c<move>
viper.texi(,3706) Change upper-case characters in the region to lower-case.
viper.texi(,3707) @item #C<move>
viper.texi(,3708) Change lower-case characters in the region to upper-case.
viper.texi(,3709) @item #q<move>
viper.texi(,3710) Insert specified string at the beginning of each line in the region
viper.texi(,3711) @item C-c M-p and C-c M-n
viper.texi(,3712) In Insert and Replace states, these keys are bound to commands that peruse
viper.texi(,3713) the history of the text
viper.texi(,3714) previously inserted in other insert or replace commands.  By repeatedly typing
viper.texi(,3715) @kbd{C-c M-p} or @kbd{C-c M-n}, you will cause Viper to
viper.texi(,3716) insert these previously used strings one by one.
viper.texi(,3717) When a new string is inserted, the previous one is deleted.
viper.texi(,3718) 
viper.texi(,3719) In Vi state, these keys are bound to functions that peruse the history of
viper.texi(,3720) destructive Vi commands.
viper.texi(,3721) @xref{Viper Specials}, for details.
viper.texi(,3722) @end table
viper.texi(,3723) @kindex @kbd{C-c M-p}
viper.texi(,3724) @kindex @kbd{C-c M-n}
viper.texi(,3725) @kindex @kbd{#q<move> }
viper.texi(,3726) @kindex @kbd{#C<move>}
viper.texi(,3727) @kindex @kbd{#c<move>}
viper.texi(,3728) @kindex @kbd{&}
viper.texi(,3729) @kindex @kbd{\&}
viper.texi(,3730) @findex @kbd{:substitute/<pat>/<repl>/<f>}
viper.texi(,3731) @findex @kbd{:s/<pat>/<repl>/<f>}
viper.texi(,3732) @findex @kbd{:copy [z]}
viper.texi(,3733) @findex @kbd{:t [z]}
viper.texi(,3734) @findex @kbd{:move [z]}
viper.texi(,3735) @kindex @kbd{J}
viper.texi(,3736) @kindex @kbd{~}
viper.texi(,3737) @kindex @kbd{=<move>}
viper.texi(,3738) @kindex @kbd{C}
viper.texi(,3739) @kindex @kbd{cc}
viper.texi(,3740) @kindex @kbd{c<move>}
viper.texi(,3741) @kindex @kbd{S}
viper.texi(,3742) @kindex @kbd{s}
viper.texi(,3743) @kindex @kbd{R}
viper.texi(,3744) @kindex @kbd{r<char>}
viper.texi(,3745) 
viper.texi(,3746) @node Search and Replace, Yanking, Changing Text,Text Handling
viper.texi(,3747) @subsection Search and Replace
viper.texi(,3748) 
viper.texi(,3749) @xref{Groundwork}, for Ex address syntax.  @xref{Options}, to see how to
viper.texi(,3750) get literal (non-regular-expression) search and how to stop search from
viper.texi(,3751) wrapping around.
viper.texi(,3752) 
viper.texi(,3753) @table @kbd
viper.texi(,3754) @item C-c /
viper.texi(,3755) Toggle case-sensitive search.  With prefix argument, toggle vanilla/regular
viper.texi(,3756) expression search.
viper.texi(,3757) @item <count>  /<string>
viper.texi(,3758) To the <count>th occurrence of <string>.
viper.texi(,3759) 
viper.texi(,3760) Viper does not parse search patterns and does not expand special symbols
viper.texi(,3761) found there (e.g., @samp{~} is not expanded to the result of the previous
viper.texi(,3762) substitution).
viper.texi(,3763) 
viper.texi(,3764) @item <count>  ?<string>
viper.texi(,3765) To the <count>th previous occurrence of <string>.
viper.texi(,3766) @item <count>  g<move>
viper.texi(,3767) Search for the text described by move.  (off by default)
viper.texi(,3768) @item n
viper.texi(,3769) Repeat latest @kbd{/} @kbd{?} (next).
viper.texi(,3770) @item N
viper.texi(,3771) Idem in opposite direction.
viper.texi(,3772) @item %
viper.texi(,3773) Find the next bracket and go to its match
viper.texi(,3774) @item :[x,y]g/<string>/<cmd>
viper.texi(,3775) @cindex text processing
viper.texi(,3776) Search globally [from line x to y] for <string>
viper.texi(,3777) and execute the Ex <cmd> on each occurrence.
viper.texi(,3778) @item :[x,y]v/<string>/<cmd>
viper.texi(,3779) Execute <cmd> on the lines that don't match.
viper.texi(,3780) @item #g<move>
viper.texi(,3781) Execute the last keyboard macro for each line in the region.
viper.texi(,3782) @xref{Macros and Registers}, for more info.
viper.texi(,3783) @item Q
viper.texi(,3784) Query Replace.
viper.texi(,3785) @item :ta <name>
viper.texi(,3786) Search in the tags file where <name> is defined (file, line), and go to it.
viper.texi(,3787) @item  :[x,y]s/<pat>/<repl>/<f>
viper.texi(,3788) Substitute (on lines x through y) the pattern <pat> (default the last
viper.texi(,3789) pattern) with <repl>.  Useful
viper.texi(,3790) flags <f> are @samp{g} for @samp{global} (i.e.@: change every
viper.texi(,3791) non-overlapping occurrence of <pat>) and @samp{c} for
viper.texi(,3792) @samp{confirm} (type @samp{y} to confirm a particular
viper.texi(,3793) substitution, else @samp{n}).  Instead of @kbd{/} any
viper.texi(,3794) punctuation character other than <space> <tab> and <lf> can be used as
viper.texi(,3795) delimiter.
viper.texi(,3796) 
viper.texi(,3797) Note: @emph{The newline character (inserted as @kbd{C-qC-j})
viper.texi(,3798) can be used in <repl>}.
viper.texi(,3799) @item  &
viper.texi(,3800) Repeat latest Ex substitute command, e.g.@: @kbd{:s/wrong/right}.
viper.texi(,3801) @item :global /<pattern>/<ex-command>
viper.texi(,3802) @itemx :g /<pattern>/<ex-command>
viper.texi(,3803) Execute <ex-command> on all lines that match <pattern>.
viper.texi(,3804) @item :vglobal /<pattern>/<ex-command>
viper.texi(,3805) @itemx :v /<pattern>/<ex-command>
viper.texi(,3806) Execute <ex-command> on all lines that do not match <pattern>.
viper.texi(,3807) @end table
viper.texi(,3808) @kindex @kbd{&}
viper.texi(,3809) @findex @kbd{:substitute/<pat>/<repl>/<f>}
viper.texi(,3810) @kindex @kbd{Q}
viper.texi(,3811) @kindex @kbd{#g<move>}
viper.texi(,3812) @findex @kbd{:v}
viper.texi(,3813) @findex @kbd{:g}
viper.texi(,3814) @findex @kbd{:global}
viper.texi(,3815) @findex @kbd{:vglobal}
viper.texi(,3816) @findex @kbd{:tag <name>}
viper.texi(,3817) @kindex @kbd{%}
viper.texi(,3818) @kindex @kbd{N}
viper.texi(,3819) @kindex @kbd{n}
viper.texi(,3820) @kindex @kbd{g<move>}
viper.texi(,3821) @kindex @kbd{?<string>}
viper.texi(,3822) @kindex @kbd{/<string>}
viper.texi(,3823) 
viper.texi(,3824) @node Yanking,Undoing,Search and Replace,Text Handling
viper.texi(,3825) @subsection Yanking
viper.texi(,3826) 
viper.texi(,3827) @cindex cut and paste
viper.texi(,3828) @cindex paste
viper.texi(,3829) 
viper.texi(,3830) @table @kbd
viper.texi(,3831) @item <count>  y<move>
viper.texi(,3832) Yank from begin to endpoint of <count><move>.
viper.texi(,3833) @item <count>  "<a-z>y<move>
viper.texi(,3834) Yank from begin to endpoint of <count><move> to register.
viper.texi(,3835) @item <count>  "<A-Z>y<move>
viper.texi(,3836) Yank from begin to endpoint of <count><move> and append
viper.texi(,3837) to register.
viper.texi(,3838) @item <count>  yy
viper.texi(,3839) <count> lines.
viper.texi(,3840) @item <count>  Y
viper.texi(,3841) Idem (should be equivalent to @kbd{y$} though).
viper.texi(,3842) @item  m<a-z>
viper.texi(,3843) Mark the cursor position with a letter.
viper.texi(,3844) @item [<a-z>
viper.texi(,3845) Show contents of textmarker.
viper.texi(,3846) @item ]<a-z>
viper.texi(,3847) Show contents of register.
viper.texi(,3848) @item <count>  ["<a-z1-9>]p
viper.texi(,3849) Put the contents of the (default undo) buffer
viper.texi(,3850) <count> times after the cursor.  The register will
viper.texi(,3851) be automatically down-cased.
viper.texi(,3852) @item <count>  ["<a-z1-9>]P
viper.texi(,3853) Put the contents of the (default undo) buffer
viper.texi(,3854) <count> times before the cursor.  The register will
viper.texi(,3855) @end table
viper.texi(,3856) @kindex @kbd{P}
viper.texi(,3857) @kindex @kbd{p}
viper.texi(,3858) @kindex @kbd{"<a-z1-9>p}
viper.texi(,3859) @kindex @kbd{"<a-z1-9>P}
viper.texi(,3860) @kindex @kbd{]<a-z>}
viper.texi(,3861) @kindex @kbd{[<a-z>}
viper.texi(,3862) @kindex @kbd{m<a-z>}
viper.texi(,3863) @kindex @kbd{Y}
viper.texi(,3864) @kindex @kbd{yy}
viper.texi(,3865) @kindex @kbd{"<A-Z>y<move>}
viper.texi(,3866) @kindex @kbd{"<a-z>y<move>}
viper.texi(,3867) @kindex @kbd{y<move>}
viper.texi(,3868) @kindex @kbd{yank}
viper.texi(,3869) @findex @kbd{:yank}
viper.texi(,3870) 
viper.texi(,3871) @node Undoing,, Yanking,Text Handling
viper.texi(,3872) @subsection Undoing
viper.texi(,3873) 
viper.texi(,3874) @cindex undo
viper.texi(,3875) @cindex backup files
viper.texi(,3876) 
viper.texi(,3877) @table @kbd
viper.texi(,3878) @item  u U
viper.texi(,3879) Undo the latest change.
viper.texi(,3880) @item  .
viper.texi(,3881) Repeat undo.
viper.texi(,3882) @item :q!
viper.texi(,3883) Quit Vi without writing.
viper.texi(,3884) @item :e!
viper.texi(,3885) Re-edit a messed-up file.
viper.texi(,3886) @item :rec
viper.texi(,3887) Recover file from autosave.  Viper also creates backup files
viper.texi(,3888) that have a @samp{~} appended to them.
viper.texi(,3889) @end table
viper.texi(,3890) @findex @kbd{:rec}
viper.texi(,3891) @findex @kbd{:e!}
viper.texi(,3892) @findex @kbd{:q!}
viper.texi(,3893) @kindex @kbd{.}
viper.texi(,3894) @kindex @kbd{U}
viper.texi(,3895) @kindex @kbd{u}
viper.texi(,3896) 
viper.texi(,3897) @node Display, File and Buffer Handling, Text Handling, Commands
viper.texi(,3898) @section Display
viper.texi(,3899) 
viper.texi(,3900) @cindex scrolling
viper.texi(,3901) 
viper.texi(,3902) @table @kbd
viper.texi(,3903) @item C-g
viper.texi(,3904) At user level 1,
viper.texi(,3905) give file name, status, current line number
viper.texi(,3906) and relative position.@*
viper.texi(,3907) At user levels 2 and higher, abort the current command.
viper.texi(,3908) @item C-c g
viper.texi(,3909) Give file name, status, current line number and relative position -- all
viper.texi(,3910) user levels.
viper.texi(,3911) @item C-l
viper.texi(,3912) Refresh the screen.
viper.texi(,3913) @item <count> C-e
viper.texi(,3914) Expose <count> more lines at bottom, cursor stays put (if possible).
viper.texi(,3915) @item <count> C-y
viper.texi(,3916) Expose <count> more lines at top, cursor stays put (if possible).
viper.texi(,3917) @item <count> C-d
viper.texi(,3918) Scroll <count> lines downward (default the number of the previous scroll;
viper.texi(,3919) initialization: half a page).
viper.texi(,3920) @item <count> C-u
viper.texi(,3921) Scroll <count> lines upward (default the number of the previous scroll;
viper.texi(,3922) initialization: half a page).
viper.texi(,3923) @item <count> C-f
viper.texi(,3924) <count> pages forward.
viper.texi(,3925) @item <count> C-b
viper.texi(,3926) <count> pages backward (in older versions @kbd{C-b} only works without count).
viper.texi(,3927) @item <count> z<cr>
viper.texi(,3928) @item zH
viper.texi(,3929) Put line <count> at the top of the window (default the current line).
viper.texi(,3930) @item <count> z-
viper.texi(,3931) @item zL
viper.texi(,3932) Put line <count> at the bottom of the window
viper.texi(,3933) (default the current line).
viper.texi(,3934) @item <count> z.
viper.texi(,3935) @item zM
viper.texi(,3936) Put line <count> in the center of the window
viper.texi(,3937) (default the current line).
viper.texi(,3938) @end table
viper.texi(,3939) @kindex @kbd{zM}
viper.texi(,3940) @kindex @kbd{zL}
viper.texi(,3941) @kindex @kbd{zH}
viper.texi(,3942) @kindex @kbd{z<cr>}
viper.texi(,3943) @kindex @kbd{z.}
viper.texi(,3944) @kindex @kbd{z-}
viper.texi(,3945) @kindex @kbd{z<cr>}
viper.texi(,3946) @kindex @kbd{C-b}
viper.texi(,3947) @kindex @kbd{C-f}
viper.texi(,3948) @kindex @kbd{C-u}
viper.texi(,3949) @kindex @kbd{C-d}
viper.texi(,3950) @kindex @kbd{C-y}
viper.texi(,3951) @kindex @kbd{C-e}
viper.texi(,3952) @kindex @kbd{C-l}
viper.texi(,3953) @kindex @kbd{C-g}
viper.texi(,3954) 
viper.texi(,3955) 
viper.texi(,3956) @node File and Buffer Handling, Mapping, Display,Commands
viper.texi(,3957) @section File and Buffer Handling
viper.texi(,3958) 
viper.texi(,3959) @cindex multiple files
viper.texi(,3960) 
viper.texi(,3961) In all file handling commands, space should be typed before entering the file
viper.texi(,3962) name.  If you need to type a modifier, such as @kbd{>>} or @kbd{!}, don't
viper.texi(,3963) put any space between the command and the modifier.
viper.texi(,3964) 
viper.texi(,3965) Note that many Ex commands, e.g., @kbd{:w}, accept command arguments. The
viper.texi(,3966) effect is that the command would start acting on the current region. For
viper.texi(,3967) instance, if the current region spans the lines 11 through 22, then if you
viper.texi(,3968) type @kbd{1:w} you would see @samp{:11,22w} in the minibuffer.
viper.texi(,3969) 
viper.texi(,3970) @table @kbd
viper.texi(,3971) @item :q
viper.texi(,3972) Quit buffer except if modified.
viper.texi(,3973) @item :q!
viper.texi(,3974) Quit buffer without checking.  In Viper, these two commands
viper.texi(,3975) are identical.  Confirmation is required if exiting modified buffers that
viper.texi(,3976) visit files.
viper.texi(,3977) @item :suspend
viper.texi(,3978) @item :stop
viper.texi(,3979) Suspend Viper
viper.texi(,3980) @item :[x,y] w
viper.texi(,3981) Write the file.  Viper makes sure that a final newline is always added to
viper.texi(,3982) any file where this newline is missing.  This is done by setting Emacs
viper.texi(,3983) variable @code{require-final-newline} to @code{t}.  If you don't like this
viper.texi(,3984) feature, use @code{setq-default} to set @code{require-final-newline} to
viper.texi(,3985) @code{nil}.  This must be done in @file{.viper} file.
viper.texi(,3986) @item :[x,y] w <name>
viper.texi(,3987) Write to the file <name>.
viper.texi(,3988) @item :[x,y] w>> <name>
viper.texi(,3989) Append the buffer to the file <name>.  There should be no space between
viper.texi(,3990) @kbd{w} and @kbd{>>}.  Type space after the @kbd{>>} and see what happens.
viper.texi(,3991) @item :w!@: <name>
viper.texi(,3992) Overwrite the file <name>.  In Viper, @kbd{:w} and @kbd{:w!} are identical.
viper.texi(,3993) Confirmation is required for writing to an existing file (if this is not
viper.texi(,3994) the file the buffer is visiting) or to a read-only file.
viper.texi(,3995) @item :x,y w <name>
viper.texi(,3996) Write lines x through y to the file <name>.
viper.texi(,3997) @item :wq
viper.texi(,3998) Write the file and kill buffer.
viper.texi(,3999) @item :r <file> [<file> ...]
viper.texi(,4000) Read file into a buffer, inserting its contents after the current line.
viper.texi(,4001) @item :xit
viper.texi(,4002) Same as @kbd{:wq}.
viper.texi(,4003) @item :Write
viper.texi(,4004) @itemx :W
viper.texi(,4005) Save all unsaved buffers, asking for confirmation.
viper.texi(,4006) @item :WWrite
viper.texi(,4007) @itemx :WW
viper.texi(,4008) Like @kbd{W}, but without asking for confirmation.
viper.texi(,4009) @item ZZ
viper.texi(,4010) Save current buffer and kill it.  If user level is 1, then save all files
viper.texi(,4011) and kill Emacs.  Killing Emacs is the wrong way to use it, so you should
viper.texi(,4012) switch to higher user levels as soon as possible.
viper.texi(,4013) @item :x [<file>]
viper.texi(,4014) Save and kill buffer.
viper.texi(,4015) @item :x!@: [<file>]
viper.texi(,4016) @kbd{:w![<file>]} and @kbd{:q}.
viper.texi(,4017) @item :pre
viper.texi(,4018) Preserve the file -- autosave buffers.
viper.texi(,4019) @item :rec
viper.texi(,4020) Recover file from autosave.
viper.texi(,4021) @item :f [<file>]
viper.texi(,4022) without the argument, prints file name and character/line information afout
viper.texi(,4023) the currently visited file. With an argument, sets the currently visited
viper.texi(,4024) filename to @file{file}.
viper.texi(,4025) @item :cd [<dir>]
viper.texi(,4026) Set the working directory to <dir> (default home directory).
viper.texi(,4027) @item :pwd
viper.texi(,4028) Print present working directory.
viper.texi(,4029) @item :e [+<cmd>] <files>
viper.texi(,4030) Edit files.  If no filename is given, edit the file visited by the current
viper.texi(,4031) buffer.  If buffer was modified or the file changed on disk, ask for
viper.texi(,4032) confirmation.  Unlike Vi, Viper allows @kbd{:e} to take multiple arguments.
viper.texi(,4033) The first file is edited the same way as in Vi.  The rest are visited
viper.texi(,4034) in the usual Emacs way.
viper.texi(,4035) @item :e!@: [+<cmd>] <files>
viper.texi(,4036) Re-edit file.  If no filename, re-edit current file.
viper.texi(,4037) In Viper, unlike Vi, @kbd{e!} is identical to @kbd{:e}.  In both cases, the
viper.texi(,4038) user is asked to confirm if there is a danger of discarding changes to a
viper.texi(,4039) buffer.
viper.texi(,4040) @item :q!
viper.texi(,4041) Quit Vi without writing.
viper.texi(,4042) @item C-^
viper.texi(,4043) Edit the alternate (normally the previous) file.
viper.texi(,4044) @item :rew
viper.texi(,4045) Obsolete
viper.texi(,4046) @item :args
viper.texi(,4047) List files not shown anywhere with counts for next
viper.texi(,4048) @item :n [count]  [+<cmd>] [<files>]
viper.texi(,4049) Edit <count> file, or edit files.  The count comes from @kbd{:args}.  
viper.texi(,4050) @item :N [count] [+<cmd>] [<files>] 
viper.texi(,4051) Like @kbd{:n}, but the meaning of the variable
viper.texi(,4052) @var{ex-cycle-other-window} is reversed.
viper.texi(,4053) @item :b
viper.texi(,4054) Switch to another buffer.  If @var{ex-cycle-other-window} is @code{t},
viper.texi(,4055) switch in another window.  Buffer completion is supported.
viper.texi(,4056) The variable @var{viper-read-buffer-function} controls which function is
viper.texi(,4057) actually used to read the buffer name. The default is @code{read-buffer},
viper.texi(,4058) but better alternatives are also available in Emacs (e.g.,
viper.texi(,4059) @code{iswitchb-read-buffer}).
viper.texi(,4060) @vindex @var{viper-read-buffer-function}
viper.texi(,4061) @item :B
viper.texi(,4062) Like @kbd{:b}, but the meaning of @var{ex-cycle-other-window} is reversed.
viper.texi(,4063) @item :<address>r <name>
viper.texi(,4064) Read the file <name> into the buffer after the line <address>.
viper.texi(,4065) @item v, V, C-v
viper.texi(,4066) Edit a file in current or another window, or in another frame.  File name
viper.texi(,4067) is typed in Minibuffer.  File completion and history are supported.
viper.texi(,4068) @end table
viper.texi(,4069) @kindex @kbd{v}
viper.texi(,4070) @kindex @kbd{V}
viper.texi(,4071) @findex @kbd{:args}
viper.texi(,4072) @findex @kbd{:rew}
viper.texi(,4073) @kindex @kbd{C-^}
viper.texi(,4074) @findex @kbd{:e!@: [<files>]}
viper.texi(,4075) @findex @kbd{:e [<files>]}
viper.texi(,4076) @findex @kbd{:edit [<files>]}
viper.texi(,4077) @findex @kbd{:edit!@: [<files>]}
viper.texi(,4078) @findex @kbd{:q!}
viper.texi(,4079) @findex @kbd{:q}
viper.texi(,4080) @findex @kbd{:quit}
viper.texi(,4081) @findex @kbd{:quit!}
viper.texi(,4082) @findex @kbd{:f}
viper.texi(,4083) @findex @kbd{:rec}
viper.texi(,4084) @findex @kbd{:r}
viper.texi(,4085) @findex @kbd{:read}
viper.texi(,4086) @findex @kbd{:pre}
viper.texi(,4087) @kindex @kbd{ZZ}
viper.texi(,4088) @findex @kbd{:wq}
viper.texi(,4089) @findex @kbd{:w <file>}
viper.texi(,4090) @findex @kbd{:w!@: <file>}
viper.texi(,4091) @findex @kbd{:w >> <file>}
viper.texi(,4092) @findex @kbd{:write <file>}
viper.texi(,4093) @findex @kbd{:write!@: <file>}
viper.texi(,4094) @findex @kbd{:write >> <file>}
viper.texi(,4095) @findex @kbd{:W}
viper.texi(,4096) @findex @kbd{:WW}
viper.texi(,4097) @findex @kbd{:Write}
viper.texi(,4098) @findex @kbd{:WWrite}
viper.texi(,4099) @findex @kbd{:WWrite}
viper.texi(,4100) @findex @kbd{:x}
viper.texi(,4101) @findex @kbd{:x!}
viper.texi(,4102) @findex @kbd{:suspend}
viper.texi(,4103) @findex @kbd{:stop}
viper.texi(,4104) @findex @kbd{:n [<count> | <file>]}
viper.texi(,4105) @findex @kbd{:cd [<dir>]}
viper.texi(,4106) @findex @kbd{:pwd}
viper.texi(,4107) 
viper.texi(,4108) @node Mapping, Shell Commands, File and Buffer Handling, Commands
viper.texi(,4109) @section Mapping
viper.texi(,4110) 
viper.texi(,4111) @cindex key bindings
viper.texi(,4112) @cindex key mapping
viper.texi(,4113) 
viper.texi(,4114) @table @kbd
viper.texi(,4115) @item :map <string>
viper.texi(,4116) Start defining a Vi-style keyboard macro.
viper.texi(,4117) For instance, typing
viper.texi(,4118) @kbd{:map www} followed by @kbd{:!wc %} and then typing @kbd{C-x )}
viper.texi(,4119) will cause @kbd{www} to run wc on
viper.texi(,4120) current file (Vi replaces @samp{%} with the current file name).
viper.texi(,4121) @item C-x )
viper.texi(,4122) Finish defining a keyboard macro.
viper.texi(,4123) In Viper, this command completes the process of defining all keyboard
viper.texi(,4124) macros, whether they are Emacs-style or Vi-style.
viper.texi(,4125) This is a departure from Vi, needed to allow WYSIWYG mapping of
viper.texi(,4126) keyboard macros and to permit the use of function keys and arbitrary Emacs
viper.texi(,4127) functions in the macros.
viper.texi(,4128) @item :unmap <string>
viper.texi(,4129) Deprive <string> of its mappings in Vi state.
viper.texi(,4130) @item :map!@: <string>
viper.texi(,4131) Map a macro for Insert state.
viper.texi(,4132) @item :unmap!@: <string>
viper.texi(,4133) Deprive <string> of its mapping in Insert state (see @kbd{:unmap}).
viper.texi(,4134) @item @@<a-z>
viper.texi(,4135) In Vi state,
viper.texi(,4136) execute the contents of register as a command.
viper.texi(,4137) @item @@@@
viper.texi(,4138) In Vi state,
viper.texi(,4139) repeat last register command.
viper.texi(,4140) @item @@#
viper.texi(,4141) In Vi state,
viper.texi(,4142) begin keyboard macro.  End with @@<a-z>.  This will
viper.texi(,4143) put the macro in the proper register.  Register will
viper.texi(,4144) be automatically down-cased.
viper.texi(,4145) @xref{Macros and Registers}, for more info.
viper.texi(,4146) @item @@!<a-z>
viper.texi(,4147) In Vi state,
viper.texi(,4148) yank anonymous macro to register
viper.texi(,4149) @item *
viper.texi(,4150) In Vi state,
viper.texi(,4151) execute anonymous macro (defined by C-x( and C-x )).
viper.texi(,4152) @item C-x e
viper.texi(,4153) Like @kbd{*}, but works in all Viper states.
viper.texi(,4154) @item #g<move>
viper.texi(,4155) Execute the last keyboard macro for each line in the region.
viper.texi(,4156) @xref{Macros and Registers}, for more info.
viper.texi(,4157) @item [<a-z>
viper.texi(,4158) Show contents of textmarker.
viper.texi(,4159) @item ]<a-z>
viper.texi(,4160) Show contents of register.
viper.texi(,4161) @end table
viper.texi(,4162) @kindex @kbd{]<a-z>}
viper.texi(,4163) @kindex @kbd{[<a-z>}
viper.texi(,4164) @kindex @kbd{#g<move>}
viper.texi(,4165) @kindex @kbd{*}
viper.texi(,4166) @kindex @kbd{@@!<a-z>}
viper.texi(,4167) @kindex @kbd{@@#}
viper.texi(,4168) @kindex @kbd{@@@@}
viper.texi(,4169) @kindex @kbd{@@<a-z>}
viper.texi(,4170) @findex @kbd{:unmap <char>}
viper.texi(,4171) @findex @kbd{:map <char> <seq>}
viper.texi(,4172) @findex @kbd{:unmap!@: <char>}
viper.texi(,4173) @findex @kbd{:map!@: <char> <seq>}
viper.texi(,4174) 
viper.texi(,4175) @node Shell Commands, Options, Mapping, Commands
viper.texi(,4176) @section Shell Commands
viper.texi(,4177) 
viper.texi(,4178) @cindex % (Current file)
viper.texi(,4179) 
viper.texi(,4180) The symbol @samp{%} is used in Ex shell commands to mean current file.  If
viper.texi(,4181) you want a @samp{%} in your command, it must be escaped as @samp{\%}.
viper.texi(,4182) @cindex @samp{%} (Ex address)
viper.texi(,4183) However if @samp{%} is the first character, it stands as the address for
viper.texi(,4184) the whole file.
viper.texi(,4185) @cindex @samp{#} (Previous file)
viper.texi(,4186) Similarly, @samp{#} expands to the previous file.  The previous file is the
viper.texi(,4187) first file in @kbd{:args} listing.  This defaults to the previous file in
viper.texi(,4188) the VI sense if you have one window.@refill
viper.texi(,4189) 
viper.texi(,4190) Symbols @samp{%} and @samp{#} are also used in the Ex commands @kbd{:e} and
viper.texi(,4191) @kbd{:r <shell-cmd>}.  The commands @kbd{:w} and the regular @kbd{:r
viper.texi(,4192) <file>} command don't support these meta symbols, because file history is a
viper.texi(,4193) better mechanism.
viper.texi(,4194) 
viper.texi(,4195) @cindex shell commands
viper.texi(,4196) 
viper.texi(,4197) @table @kbd
viper.texi(,4198) @item :sh
viper.texi(,4199) Execute a subshell in another window
viper.texi(,4200) @item :[x,y]!<cmd>
viper.texi(,4201) Execute a shell <cmd> [on lines x through y;
viper.texi(,4202) % is replace by current file, \% is changed to %
viper.texi(,4203) @item :[x,y]!!@: [<args>]
viper.texi(,4204) Repeat last shell command [and append <args>].
viper.texi(,4205) @item :!<cmd>
viper.texi(,4206) Just execute command and display result in a buffer.
viper.texi(,4207) @item :!!@: <args>
viper.texi(,4208) Repeat last shell command and append <args>
viper.texi(,4209) @item <count> !<move><cmd>
viper.texi(,4210) The shell executes <cmd>, with standard
viper.texi(,4211) input the lines described by <count><move>,
viper.texi(,4212) next the standard output replaces those lines
viper.texi(,4213) (think of @samp{cb}, @samp{sort}, @samp{nroff}, etc.).
viper.texi(,4214) @item <count> !!<cmd>
viper.texi(,4215) Give <count> lines as standard input to the
viper.texi(,4216) shell <cmd>, next let the standard output
viper.texi(,4217) replace those lines.
viper.texi(,4218) @item :[x,y] w !<cmd>
viper.texi(,4219) Let lines x to y be standard input for <cmd>
viper.texi(,4220) (notice the <sp> between @kbd{w} and @kbd{!}).
viper.texi(,4221) @item :<address>r !<cmd>
viper.texi(,4222) Put the output of <cmd> after the line <address> (default current).
viper.texi(,4223) @item :<address>r <name>
viper.texi(,4224) Read the file <name> into the buffer after the line <address> (default
viper.texi(,4225) current).
viper.texi(,4226) @item :make
viper.texi(,4227) Run the make command in the current directory.
viper.texi(,4228) @end table
viper.texi(,4229) @findex @kbd{:<address>r <name>}
viper.texi(,4230) @findex @kbd{:<address>r !<cmd>}
viper.texi(,4231) @findex @kbd{!<cmd>}
viper.texi(,4232) @findex @kbd{!!<cmd>}
viper.texi(,4233) @findex @kbd{!<move><cmd>}
viper.texi(,4234) @findex @kbd{:w !<cmd>}
viper.texi(,4235) @findex @kbd{:x,y w !<cmd>}
viper.texi(,4236) @findex @kbd{:!!@: <args>}
viper.texi(,4237) @findex @kbd{:!<cmd>}
viper.texi(,4238) @findex @kbd{:sh}
viper.texi(,4239) @findex @kbd{:make}
viper.texi(,4240) 
viper.texi(,4241) @node Options,Emacs Related Commands,Shell Commands,Commands
viper.texi(,4242) @section Options
viper.texi(,4243) 
viper.texi(,4244) @cindex Vi options
viper.texi(,4245) 
viper.texi(,4246) @table @kbd
viper.texi(,4247) @item autoindent
viper.texi(,4248) @itemx ai
viper.texi(,4249) @cindex autoindent
viper.texi(,4250) autoindent -- In append mode after a <cr> the
viper.texi(,4251) cursor will move directly below the first
viper.texi(,4252) character on the previous line.
viper.texi(,4253) This setting affects the current buffer only.
viper.texi(,4254) @item autoindent-global
viper.texi(,4255) @itemx ai-global
viper.texi(,4256) Same as `autoindent', but affects all buffers.
viper.texi(,4257) @item noautoindent
viper.texi(,4258) @itemx noai
viper.texi(,4259) Cancel autoindent.
viper.texi(,4260) @item noautoindent-global
viper.texi(,4261) @itemx noai-g
viper.texi(,4262) Cancel autoindent-global.
viper.texi(,4263) @item ignorecase
viper.texi(,4264) @itemx ic
viper.texi(,4265) @cindex case and searching
viper.texi(,4266) ignorecase -- No distinction between upper and lower cases when searching.
viper.texi(,4267) @item noignorecase
viper.texi(,4268) @itemx noic
viper.texi(,4269) Cancel ignorecase.
viper.texi(,4270) @item magic
viper.texi(,4271) @itemx ma
viper.texi(,4272) @cindex literal searching
viper.texi(,4273) Regular expressions used in searches; nomagic means no regexps.
viper.texi(,4274) @item nomagic
viper.texi(,4275) @item noma
viper.texi(,4276) Cancel magic.
viper.texi(,4277) @item readonly
viper.texi(,4278) @itemx ro
viper.texi(,4279) @cindex readonly files
viper.texi(,4280) readonly -- The file is not to be changed.
viper.texi(,4281) If the user attempts to write to this file, confirmation will be requested.
viper.texi(,4282) @item noreadonly
viper.texi(,4283) @itemx noro
viper.texi(,4284) Cancel readonly.
viper.texi(,4285) @item shell=<string>
viper.texi(,4286) @itemx sh=<string>
viper.texi(,4287) @cindex shell
viper.texi(,4288) shell -- The program to be used for shell escapes
viper.texi(,4289) (default @samp{$SHELL} (default @file{/bin/sh})).
viper.texi(,4290) @item shiftwidth=<count>
viper.texi(,4291) @itemx sw=<count>
viper.texi(,4292) @cindex layout
viper.texi(,4293) @cindex shifting text
viper.texi(,4294) shiftwidth -- Gives the shiftwidth (default 8 positions).
viper.texi(,4295) @item showmatch
viper.texi(,4296) @itemx sm
viper.texi(,4297) @cindex paren matching
viper.texi(,4298) @cindex matching parens
viper.texi(,4299) showmatch -- Whenever you append a @kbd{)}, Vi shows
viper.texi(,4300) its match if it's on the same page; also with
viper.texi(,4301) @kbd{@{} and @kbd{@}}.  If there's no match, Vi will beep.
viper.texi(,4302) @item noshowmatch
viper.texi(,4303) @itemx nosm
viper.texi(,4304) Cancel showmatch.
viper.texi(,4305) @item tabstop=<count>
viper.texi(,4306) @itemx ts=<count>
viper.texi(,4307) @cindex changing tab width
viper.texi(,4308) @cindex tabbing
viper.texi(,4309) tabstop -- The length of a <ht>; warning: this is
viper.texi(,4310) only IN the editor, outside of it <ht>s have
viper.texi(,4311) their normal length (default 8 positions).
viper.texi(,4312) This setting affects the current buffer only.
viper.texi(,4313) @item tabstop-global
viper.texi(,4314) @itemx ts-g
viper.texi(,4315) Same as `tabstop', but affects all buffers.
viper.texi(,4316) @item wrapmargin=<count>
viper.texi(,4317) @itemx wm=<count>
viper.texi(,4318) @cindex auto fill
viper.texi(,4319) @cindex word wrap
viper.texi(,4320) wrapmargin -- In append mode Vi automatically
viper.texi(,4321) puts a <lf> whenever there is a <sp> or <ht>
viper.texi(,4322) within <wm> columns from the right margin.
viper.texi(,4323) @item wrapscan
viper.texi(,4324) @itemx ws
viper.texi(,4325) @cindex searching
viper.texi(,4326) wrapscan -- When searching, the end is
viper.texi(,4327) considered @samp{stuck} to the begin of the file.
viper.texi(,4328) @item nowrapscan
viper.texi(,4329) @itemx nows
viper.texi(,4330) Cancel wrapscan.
viper.texi(,4331) @item :set <option>
viper.texi(,4332) Turn <option> on.
viper.texi(,4333) @item :set no<option>
viper.texi(,4334) Turn <option> off.
viper.texi(,4335) @item :set <option>=<value>
viper.texi(,4336) Set <option> to <value>.
viper.texi(,4337) @end table
viper.texi(,4338) @findex @kbd{:set <option>=<value>}
viper.texi(,4339) @findex @kbd{:set no<option>}
viper.texi(,4340) @findex @kbd{:set <option>}
viper.texi(,4341) @findex @kbd{:set ws}
viper.texi(,4342) @findex @kbd{:set wrapscan}
viper.texi(,4343) @findex @kbd{:set wm=<count>}
viper.texi(,4344) @findex @kbd{:set wrapmargin=<count>}
viper.texi(,4345) @findex @kbd{:set ts=<count>}
viper.texi(,4346) @findex @kbd{:set tabstop=<count>}
viper.texi(,4347) @findex @kbd{:set tab-stop-local=<count>}
viper.texi(,4348) @findex @kbd{:set sm}
viper.texi(,4349) @findex @kbd{:set showmatch}
viper.texi(,4350) @findex @kbd{:set sw=<count>}
viper.texi(,4351) @findex @kbd{:set shiftwidth=<count>}
viper.texi(,4352) @findex @kbd{:set sh=<string>}
viper.texi(,4353) @findex @kbd{:set shell=<string>}
viper.texi(,4354) @findex @kbd{:set ro}
viper.texi(,4355) @findex @kbd{:set readonly}
viper.texi(,4356) @findex @kbd{:set magic}
viper.texi(,4357) @findex @kbd{:set ic}
viper.texi(,4358) @findex @kbd{:set ignorecase}
viper.texi(,4359) @findex @kbd{:set ai}
viper.texi(,4360) @findex @kbd{:set autoindent}
viper.texi(,4361) 
viper.texi(,4362) @node Emacs Related Commands,,Options,Commands
viper.texi(,4363) @section Emacs Related Commands
viper.texi(,4364) 
viper.texi(,4365) @table @kbd
viper.texi(,4366) @item C-\
viper.texi(,4367) Begin Meta command in Vi or Insert states.  Most often used as C-\ x (M-x).
viper.texi(,4368) 
viper.texi(,4369) Note: Emacs binds @kbd{C-\} to a function that offers to change the
viper.texi(,4370) keyboard input method in the multilingual environment.  Viper overrides this
viper.texi(,4371) binding.  However, it is still possible to switch the input method by typing
viper.texi(,4372) @kbd{\ C-\} in the Vi command state and @kbd{C-z \ C-\} in the Insert state.
viper.texi(,4373) Or you can use the MULE menu on the menubar.
viper.texi(,4374) @item C-z
viper.texi(,4375) In Insert and Replace states, prepare Viper to accept the next command and
viper.texi(,4376) execute it as if Viper was in Vi state.  Then return to Insert state.
viper.texi(,4377) 
viper.texi(,4378) In Vi state, switch to Emacs state; in Emacs state, switch to Vi state.
viper.texi(,4379) @item C-c \
viper.texi(,4380) Switches to Vi state for the duration of a single command.  Then goes back
viper.texi(,4381) to the original Viper state.  Works from Vi, Insert, Replace, and Emacs states.
viper.texi(,4382) @item C-x0
viper.texi(,4383) Close Window
viper.texi(,4384) @item C-x1
viper.texi(,4385) Close Other Windows
viper.texi(,4386) @item C-x2
viper.texi(,4387) Split Window
viper.texi(,4388) @item C-xo
viper.texi(,4389) Move among windows
viper.texi(,4390) @item C-xC-f
viper.texi(,4391) Emacs find-file, useful in Insert state
viper.texi(,4392) @item C-y
viper.texi(,4393) Put back the last killed text.  Similar to Vi's @kbd{p}, but also works in
viper.texi(,4394) Insert and Replace state.  This command doesn't work in Vi command state,
viper.texi(,4395) since this binding is taken for something else.
viper.texi(,4396) @item M-y
viper.texi(,4397) Undoes the last @kbd{C-y} and puts another kill from the kill ring.
viper.texi(,4398) Using this command, you can try may different kills until you find the one
viper.texi(,4399) you need.
viper.texi(,4400) @end table
viper.texi(,4401) @kindex @kbd{M-y}
viper.texi(,4402) @kindex @kbd{C-y}
viper.texi(,4403) @kindex @kbd{C-xC-f}
viper.texi(,4404) @kindex @kbd{C-xo}
viper.texi(,4405) @kindex @kbd{C-x2}
viper.texi(,4406) @kindex @kbd{C-x1}
viper.texi(,4407) @kindex @kbd{C-x0}
viper.texi(,4408) @kindex @kbd{C-z}
viper.texi(,4409) @kindex @kbd{C-\}
viper.texi(,4410) @kindex @kbd{C-c\}
viper.texi(,4411) 
viper.texi(,4412) @node Mouse-bound Commands,,,Commands
viper.texi(,4413) @section Mouse-bound Commands
viper.texi(,4414) 
viper.texi(,4415) The following two mouse actions are normally bound to special search and
viper.texi(,4416) insert commands in of Viper:
viper.texi(,4417) 
viper.texi(,4418) @table @kbd
viper.texi(,4419) @item S-Mouse-1 (Emacs)
viper.texi(,4420) @item meta button1up (XEmacs)
viper.texi(,4421) Holding Shift (or Meta, if XEmacs) and clicking mouse button 1 will
viper.texi(,4422) initiate search for 
viper.texi(,4423) a region under the mouse pointer.
viper.texi(,4424) This command can take a prefix argument.  Note: Viper sets this
viper.texi(,4425) binding only if this mouse action is not
viper.texi(,4426) already bound to something else.
viper.texi(,4427) @xref{Viper Specials}, for more information.@refill
viper.texi(,4428) 
viper.texi(,4429) @item S-Mouse-2 (Emacs)
viper.texi(,4430) @item meta button2up (XEmacs)
viper.texi(,4431) Holding Shift (or Meta, if XEmacs) and clicking button 2 of the mouse will
viper.texi(,4432) insert a region surrounding the mouse pointer.
viper.texi(,4433) This command can also take a prefix argument.
viper.texi(,4434) Note: Viper sets this binding only if this mouse action is not
viper.texi(,4435) already bound to something else.
viper.texi(,4436) @xref{Viper Specials}, for more details.@refill
viper.texi(,4437) @end table
viper.texi(,4438) @kindex @kbd{S-Mouse-1}
viper.texi(,4439) @kindex @kbd{S-Mouse-2}
viper.texi(,4440) @kindex @kbd{meta button1up}
viper.texi(,4441) @kindex @kbd{meta button2up}
viper.texi(,4442) 
viper.texi(,4443) @node Acknowledgments,,,Top
viper.texi(,4444) @comment  node-name,  next,  previous,  up
viper.texi(,4445) @unnumbered Acknowledgments
viper.texi(,4446) 
viper.texi(,4447) Viper, formerly known as VIP-19, was written by Michael Kifer.  Viper is
viper.texi(,4448) based on the original VIP package by Masahiko Sato and on its enhancement,
viper.texi(,4449) VIP 4.4, by Aamod Sane.  This manual is an adaptation of the manual for VIP
viper.texi(,4450) 4.4, which, in turn, was based on Sato's manual for VIP 3.5.
viper.texi(,4451) 
viper.texi(,4452) Many contributors on the Net pointed out bugs and suggested a number of
viper.texi(,4453) useful features. Scott Bronson and Samuel Padgett contributed patches that
viper.texi(,4454) were incorporated in this code.  Here is a hopefully complete list of
viper.texi(,4455) contributors:
viper.texi(,4456) 
viper.texi(,4457) @example
viper.texi(,4458) aaronl@@vitelus.com (Aaron Lehmann),
viper.texi(,4459) ahg@@panix.com (Al Gelders),
viper.texi(,4460) amade@@diagram.fr (Paul-Bernard Amade),
viper.texi(,4461) ascott@@fws214.intel.com (Andy Scott),
viper.texi(,4462) bronson@@trestle.com (Scott Bronson),
viper.texi(,4463) cook@@biostat.wisc.edu (Tom Cook),
viper.texi(,4464) csdayton@@midway.uchicago.edu (Soren Dayton),
viper.texi(,4465) dave@@hellgate.utah.edu,
viper.texi(,4466) dm@@scs.cs.nyu.edu (David Mazieres),
viper.texi(,4467) dominik@@strw.LeidenUniv.nl (Carsten Dominik),
viper.texi(,4468) dwallach@@cs.princeton.edu (Dan Wallach),
viper.texi(,4469) dwight@@toolucky.llnl.gov (Dwight Shih),
viper.texi(,4470) dxc@@xprt.net (David X Callaway),
viper.texi(,4471) edmonds@@edmonds.home.cs.ubc.ca (Brian Edmonds),
viper.texi(,4472) gin@@mo.msk.ru (Golubev I.N.),
viper.texi(,4473) gviswana@@cs.wisc.edu (Guhan Viswanathan),
viper.texi(,4474) gvr@@halcyon.com (George V.@: Reilly),
viper.texi(,4475) hatazaki@@bach.convex.com (Takao Hatazaki),
viper.texi(,4476) hpz@@ibmhpz.aug.ipp-garching.mpg.de (Hans-Peter Zehrfeld),
viper.texi(,4477) jackr@@dblues.engr.sgi.com (Jack Repenning),
viper.texi(,4478) jamesm@@bga.com (D.J.@: Miller II),
viper.texi(,4479) jjm@@hplb.hpl.hp.com (Jean-Jacques Moreau),
viper.texi(,4480) jl@@cse.ogi.edu (John Launchbury),
viper.texi(,4481) jobrien@@hchp.org (John O'Brien),
viper.texi(,4482) johnw@@borland.com (John Wiegley),
viper.texi(,4483) kanze@@gabi-soft.fr (James Kanze),
viper.texi(,4484) kin@@isi.com (Kin Cho),
viper.texi(,4485) kwzh@@gnu.org (Karl Heuer),
viper.texi(,4486) lindstro@@biostat.wisc.edu (Mary Lindstrom),
viper.texi(,4487) minakaji@@osaka.email.ne.jp (Mikio Nakajima),
viper.texi(,4488) Mark.Bordas@@East.Sun.COM (Mark Bordas),
viper.texi(,4489) meyering@@comco.com (Jim Meyering),
viper.texi(,4490) martin@@xemacs.org (Martin Buchholz),
viper.texi(,4491) mbutler@@redfernnetworks.com (Malcolm Butler),
viper.texi(,4492) mveiga@@dit.upm.es (Marcelino Veiga Tuimil),
viper.texi(,4493) paulk@@summit.esg.apertus.com (Paul Keusemann),
viper.texi(,4494) pfister@@cs.stonybrook.edu (Hanspeter Pfister),
viper.texi(,4495) phil_brooks@@MENTORG.COM (Phil Brooks),
viper.texi(,4496) pogrell@@informatik.hu-berlin.de (Lutz Pogrell),
viper.texi(,4497) pradyut@@cs.uchicago.edu (Pradyut Shah),
viper.texi(,4498) roderick@@argon.org (Roderick Schertler),
viper.texi(,4499) rxga@@ulysses.att.com,
viper.texi(,4500) sawdey@@lcse.umn.edu (Aaron Sawdey),
viper.texi(,4501) simonb@@prl.philips.co.uk (Simon Blanchard),
viper.texi(,4502) spadgett1@@nc.rr.com (Samuel Padgett),
viper.texi(,4503) stephen@@farrell.org (Stephen Farrell),
viper.texi(,4504) sudish@@MindSpring.COM (Sudish Joseph),
viper.texi(,4505) schwab@@issan.informatik.uni-dortmund.de (Andreas Schwab)
viper.texi(,4506) terra@@diku.dk (Morten Welinder),
viper.texi(,4507) thanh@@informatics.muni.cz (Han The Thanh),
viper.texi(,4508) toma@@convex.convex.com,
viper.texi(,4509) vrenjak@@sun1.racal.com (Milan Vrenjak),
viper.texi(,4510) whicken@@dragon.parasoft.com (Wendell Hicken),
viper.texi(,4511) zapman@@cc.gatech.edu (Jason Zapman II),
viper.texi(,4512) @end example
viper.texi(,4513) 
viper.texi(,4514) 
viper.texi(,4515) @node Key Index,Function Index,,Top
viper.texi(,4516) @comment  node-name,  next,  previous,  up
viper.texi(,4517) @unnumbered Key Index
viper.texi(,4518) 
viper.texi(,4519) @printindex ky
viper.texi(,4520) 
viper.texi(,4521) @node Function Index,Variable Index,Key Index,Top
viper.texi(,4522) @comment  node-name,  next,  previous,  up
viper.texi(,4523) @unnumbered Function Index
viper.texi(,4524) 
viper.texi(,4525) @printindex fn
viper.texi(,4526) 
viper.texi(,4527) @node Variable Index,Package Index,Function Index,Top
viper.texi(,4528) @comment  node-name,  next,  previous,  up
viper.texi(,4529) @unnumbered Variable Index
viper.texi(,4530) 
viper.texi(,4531) @printindex vr
viper.texi(,4532) 
viper.texi(,4533) @node Package Index,Concept Index,Variable Index,Top
viper.texi(,4534) @comment  node-name,  next,  previous,  up
viper.texi(,4535) @unnumbered Package Index
viper.texi(,4536) 
viper.texi(,4537) @printindex pg
viper.texi(,4538) 
viper.texi(,4539) @node Concept Index,,Package Index,Top
viper.texi(,4540) @comment  node-name,  next,  previous,  up
viper.texi(,4541) @unnumbered Concept Index
viper.texi(,4542) 
viper.texi(,4543) @printindex cp
viper.texi(,4544) 
viper.texi(,4545) @setchapternewpage odd
viper.texi(,4546) @contents
viper.texi(,4547) @bye
