viper: States in Viper
1.3 States in Viper
===================
Viper has four states, Emacs, Vi, Insert, and Replace.
‘Emacs state’
This is the state plain vanilla Emacs is normally in. After you
have loaded Viper, ‘C-z’ will normally take you to Vi command
state. Another ‘C-z’ will take you back to Emacs state. This
toggle key can be changed, Customization You can also type
‘M-x viper-mode’ to change to Vi state.
For users who chose to set their user level to 1 at Viper setup
time, switching to Emacs state is deliberately made harder in order
to not confuse the novice user. In this case, ‘C-z’ will either
iconify Emacs (if Emacs runs as an application under X) or it will
stop Emacs (if Emacs runs on a dumb terminal or in an Xterm
window).
‘Vi state’
This is the Vi command mode. Any of the Vi commands, such as ‘i,
o, a’, ..., will take you to Insert state. All Vi commands may be
used in this mode. Most Ex commands can also be used. For a full
list of Ex commands supported by Viper, type ‘:’ and then <TAB>.
To get help on any issue, including the Ex commands, type ‘:help’.
This will invoke Viper Info (if it is installed). Then typing ‘i’
will prompt you for a topic to search in the index. Note: to
search for Ex commands in the index, you should start them with a
‘:’, e.g., ‘:WW’.
In Viper, Ex commands can be made to work on the current Emacs
region. This is done by typing a digit argument before ‘:’. For
instance, typing ‘1:’ will prompt you with something like
_:123,135_, assuming that the current region starts at line 123 and
ends at line 135. There is no need to type the line numbers, since
Viper inserts them automatically in front of the Ex command.
‘Insert state’
Insert state is the Vi insertion mode. <ESC> will take you back to
Vi state. Insert state editing can be done, including
auto-indentation. By default, Viper disables Emacs key bindings in
Insert state.
‘Replace state’
Commands like ‘cw’ invoke the Replace state. When you cross the
boundary of a replacement region (usually designated via a ‘$’
sign), it will automatically change to Insert state. You do not
have to worry about it. The key bindings remain practically the
same as in Insert state. If you type <ESC>, Viper will switch to
Vi command mode, terminating the replacement state.
The modes are indicated on the “mode line” as <E>, <I>, <V>, and <R>,
so that the multiple modes do not confuse you. Most of your editing can
be done in Vi and Insert states. Viper will try to make all new buffers
be in Vi state, but sometimes they may come up in Emacs state. ‘C-z’
will take you to Vi state in such a case. In some major modes, like
Dired, Info, Gnus, etc., you should not switch to Vi state (and Viper
will not attempt to do so) because these modes are not intended for text
editing and many of the Vi keys have special meaning there. If you plan
to read news, browse directories, read mail, etc., from Emacs (which you
should start doing soon!), you should learn about the meaning of the
various keys in those special modes (typing ‘C-h m’ in a buffer provides
help with key bindings for the major mode of that buffer).
If you switch to Vi in Dired or similar modes, no harm is done. It
is just that the special key bindings provided by those modes will be
temporarily overshadowed by Viper’s bindings. Switching back to Viper’s
Emacs state will revive the environment provided by the current major
mode.
States in Viper are orthogonal to Emacs major modes, such as C mode
or Dired mode. You can turn Viper on and off for any Emacs state. When
Viper is turned on, Vi state can be used to move around. In Insert
state, the bindings for these modes can be accessed. For beginners
(users at Viper levels 1 and 2), these bindings are suppressed in Insert
state, so that new users are not confused by the Emacs states. Note
that unless you allow Emacs bindings in Insert state, you cannot do many
interesting things, like language sensitive editing. For the novice
user (at Viper level 1), all major mode bindings are turned off in Vi
state as well. This includes the bindings for key sequences that start
with ‘C-c’, which practically means that all major mode bindings are
unsupported. Customization, to find out how to allow Emacs keys
in Insert state.
Menu