PREV Emacs State UP States in Viper NEXT Insert State

1.3.2: Vi State

This is the Vi command mode. When Viper is in Vi state, you will see the sign <V> in the mode line. Most keys will work as in Vi. The notable exceptions are:

C-x

C-x is used to invoke Emacs commands, mainly those that do window management. C-x 2 will split a window, C-x 0 will close a window. C-x 1 will close all other windows. C-xb is used to switch buffers in a window, and C-xo to move through windows. These are about the only necessary keystrokes. For the rest, see the GNU Emacs Manual.

C-c

For user levels 2 and higher, this key serves as a prefix key for the key sequences used by various major modes. For users at Viper level 1, C-c simply beeps.

C-g and C-]

These are the Emacs `quit' keys. There will be cases where you will have to use C-g to quit. Similarly, C-] is used to exit `Recursive Edits' in Emacs for which there is no comparable Vi functionality and no key-binding. Recursive edits are indicated by `[]' brackets framing the modes on the mode line. See Recursive Edit. At user level 1, C-g is bound to viper-info-on-file function instead.

C-\

Viper uses ESC as a switch between Insert and Vi states. Emacs uses ESC for Meta. The Meta key is very important in Emacs since many finctions are accessible only via that key as M-x function-name. Therefore, we need to simulate it somehow. In Viper's Vi, Insert, and Replace states, the meta key is set to be C-\. Thus, to get M-x, you should type C-\ x (if the keyboard has no Meta key). This works both in the Vi command state and in the Insert and Replace states. In Vi command state, you can also use \ ESC as the meta key.

Note: Emacs binds C-\ to a function that offers to change the keyboard input method in the multilingual environment. Viper overrides this binding. However, it is still possible to switch the input method by typing \ C-\ in the Vi command state and C-z \ C-\ in the Insert state. Or you can use the MULE menu in the menubar.

Other differences are mostly improvements. The ones you should know about are:

`Undo'

u will undo. Undo can be repeated by the . key. Undo itself can be undone. Another u will change the direction. The presence of repeatable undo means that U, undoing lines, is not very important. Therefore, U also calls viper-undo.

`Counts'

Most commands, ~, [[, p, /, ..., etc., take counts.

`Regexps'

Viper uses Emacs Regular Expressions for searches. These are a superset of Vi regular expressions, excepting the change-of-case escapes `\u', `\L', ..., etc. See Regular Expressions, for details. Files specified to :e use csh regular expressions (globbing, wildcards, what have you). However, the function viper-toggle-search-style, bound to C-c /, lets the user switch from search with regular expressions to plain vanilla search and vice versa. It also lets one switch from case-sensitive search to case-insensitive and back. See Viper Specials, for more details.

`Ex commands'

The current working directory of a buffer is automatically inserted in the minibuffer if you type :e then space. Absolute filenames are required less often in Viper. For path names, Emacs uses a convention that is slightly different from that of Unix. It is designed to minimize the need for deleting path names that Emacs provides in its prompts. (This is usually convenient, but occasionally the prompt may suggest a wrong path name for you.) If you see a prompt /usr/foo/ and you wish to edit the file ~/.viper, you don't have to erase the prompt. Instead, simply continue typing what you need. Emacs will interpret /usr/foo/~/.viper correctly. Similarly, if the prompt is ~/foo/ and you need to get to /bar/file, keep typing. Emacs interprets ~/foo//bar/ as /bar/file, since when it sees `//', it understands that ~/foo/ is to be discarded.

The command :cd will change the default directory for the current buffer. The command :e will interpret the filename argument in csh. See Customization, if you want to change the default shell. The command :next takes counts from :args, so that :rew is obsolete. Also, :args will show only the invisible files (i.e., those that are not currently seen in Emacs windows).

When applicable, Ex commands support file completion and history. This means that by typing a partial file name and then TAB, Emacs will try to complete the name or it will offer a menu of possible completions. This works similarly to Tcsh and extends the behavior of Csh. While Emacs is waiting for a file name, you can type M-p to get the previous file name you typed. Repeatedly typing M-p and M-n will let you browse through the file history.

Like file names, partially typed Ex commands can be completed by typing TAB, and Viper keeps the history of Ex commands. After typing :, you can browse through the previously entered Ex commands by typing M-p and M-n. Viper tries to rationalize when it puts Ex commands on the history list. For instance, if you typed :w! foo, only :w! will be placed on the history list. This is because the last history element is the default that can be invoked simply by typing : RET. If :w! foo were placed on the list, it would be all to easy to override valuable data in another file. Reconstructing the full command, :w! foo, from the history is still not that hard, since Viper has a separate history for file names. By typing : M-p, you will get :w! in the Minibuffer. Then, repeated M-p will get you through the file history, inserting one file name after another.

In contrast to :w! foo, if the command were :r foo, the entire command will appear in the history list. This is because having :r alone as a default is meaningless, since this command requires a file argument.

As Vi, Viper's destructive commands can be re-executed by typing `.'. However, in addition, Viper keeps track of the history of such commands. This history can be perused by typing C-c M-p and C-c M-n. Having found the appropriate command, it can be then executed by typing `.'. See Improvements over Vi, for more information.

PREV Emacs State UP States in Viper NEXT Insert State