2.9 New Commands
These commands have no Vi analogs.
- C-x, C-c
- These two keys invoke many important Emacs functions. For example, if you
hit C-x followed by 2, then the current window will be split
into 2. Except for novice users, C-c is also set to execute an Emacs
command from the current major mode. <ESC> will do the same, if you
configure <ESC> as Meta by setting
nil in your Viper customization file. See Customization.
C-\ in Insert, Replace, or Vi states will make Emacs think
Meta has been hit.
- Escape to Emacs to execute a single Emacs command. For instance,
\ <ESC> will act like a Meta key.
- Q is for query replace. By default,
each string to be replaced is treated as a regular expression. You can use
(setq viper-re-query-replace nil) in your .emacs file to
turn this off. (For normal searches, :se nomagic will work. Note
that :se nomagic turns Regexps off completely, unlike Vi).
- These keys are used to visit files. v will switch to a buffer
visiting file whose name can be entered in the minibuffer. V is
similar, but will use a window different from the current window.
C-v is like V, except that a new frame (X window) will be used
instead of a new Emacs window.
- If followed by a certain character ch, it becomes an operator whose
argument is the region determined by the motion command that follows
(indicated as <move>).
Currently, ch can be one of c, C, g, q, and
s. For instance, #qr will prompt you for a string and then
prepend this string to each line in the buffer.
- # c
- Change upper-case characters in the region to lower-case
Emacs command M-l does the same for words.
- # C
- Change lower-case characters in the region to upper-case. For instance,
# C 3 w will capitalize 3 words from the current point
Emacs command M-u does the same for words.
- # g
- Execute last keyboard macro for each line in the region
- # q
- Insert specified string at the beginning of each line in the region
viper-quote-region). The default string is composed of the comment
character(s) appropriate for the current major mode.
- # s
- Check spelling of words in the region (
The function used for spelling is determined from the variable
- Call last keyboard macro.
- m .
- Set mark at point and push old mark off the ring
- Set mark at beginning and end of buffer, respectively.
- Jump to mark and pop mark off the ring. See Mark, for more info.
- ] register
- View contents of register
- [ textmarker
- View filename and position of textmarker
Begin/end keyboard macro. @register has a different meaning when used after
a @#. See Macros and Registers, for details
- Go to end of heading.
- g <movement command>
- Search buffer for text delimited by movement command. The canonical
example is gw to search for the word under the cursor.
See Improved Search, for details.
- C-g and C-]
- Quit and Abort Recursive edit. These may be necessary on occasion.
See Vi State, for a reason.
- C-c C-g
- Hitting C-c followed by C-g will display the information on the
current buffer. This is the same as hitting C-g in Vi, but, as
explained above, C-g is needed for other purposes in Emacs.
- C-c /
- Without a prefix argument, this command toggles
case-sensitive/case-insensitive search modes and plain vanilla/regular
expression search. With the prefix argument 1, i.e.,
1 C-c /, this toggles case-sensitivity; with the prefix argument 2,
toggles plain vanilla search and search using
regular expressions. See Viper Specials, for alternative ways to invoke
- M-p and M-n
- In the minibuffer, these commands navigate through the minibuffer
histories, such as the history of search strings, Ex commands, etc.
- If the minibuffer is entered via a Viper search commands / or ?,
then typing this key inserts the last search string used by the
Emacs incremental search command (that is bound to C-s everywhere
except in this case).
- C-c M-p and C-c M-n
In Insert or Replace state, these commands let the user
peruse the history of insertion strings used in previous insert or replace
commands. Try to hit C-c M-p or C-c M-n repeatedly and see what
happens. See Viper Specials, for more.
In Vi state, these commands let the user peruse the history of Vi-style
destructive commands, such as dw, J, a, etc.
By repeatedly typing C-c M-p or C-c M-n you will cycle Viper
through the recent history of Vi commands, displaying the commands one by
an appropriate command is found, it can be executed by typing `.'.
Since typing C-c M-p is tedious, it is more convenient to bind an
appropriate function to a function key on the keyboard and use that key.
See Viper Specials, for details.
- Ex commands
- The commands :args, :next, :pre behave
differently. :pwd exists to get current directory.
The commands :b and :B switch buffers around. See File and Buffer Handling, for details.
There are also the new commands :RelatedFile and
PreviousRelatedFile (which abbreviate to R and P,
respectively. See Viper Specials, for details.
Apart from the new commands, many old commands have been enhanced. Most
notably, Vi style macros are much more powerful in Viper than in Vi. See Vi Macros, for details.