[net.emacs] VI-major mode?

aks@umcp-cs.UUCP (Alan K. Stebbens) (01/06/86)

Is there any implementation of a VI-mode available for GNU Emacs?
I've installed GNU-Emacs twice, at two different sites, and have discovered
the major resistance to its acceptance is its unfamiliarity, compounded
by the large command/keystroke-set.  When I explained to users that GNU-Emacs
could readily be extended to appear like VI, while allowing them to gradually
become accustomed to Emacs' other features, all responded with something
like "Sounds great! How do I use it?".  

So.  I have now kind-of committed myself to providing such a feature as 
a "VI mode".  I have actually started writing the functions, modelling it
after the other "modes" Lisp functions that are already part of Emacs.

In the interest of not "reinventing the wheel" (and sheer laziness), I am
now soliciting for any existing VI-mode implementations for GNU Emacs.

Below, I will list several desireable features for a VI-mode.  To make the
description of the features understandable, a brief explanation of VI's
editing modes is in order. 

As most of you are aware, VI operates in three modes: Edit Mode, Input Mode, 
and Command Mode.

Edit Mode is when keystrokes like "k", "/", ":",  are interpreted 
rather than inserted into the text. 
	
Input Mode is when these same keystrokes are inserted directly into 
the text;  certain ASCII-control characters act on the input:
^W, ^U, ^T, ^D, ESC, BS, DEL.

Command Mode is triggered in Edit Mode by one of several triggers: 
":", "/", "?", "!".  Each trigger is followed by different kinds of
arguments; in particular, "!" is followed first by an object 
descriptor, then by a command line.  The other triggers are followed
by command lines; each kind of trigger has its own command line syntax.

 
Features desireable for a VI-mode in Emacs:

	a) Implement all of VI's Edit Mode and Input Mode keystrokes.
	   Edit Mode and Input Mode would probably be implemented as
	   minor modes (would this work?).

	b) The following keystrokes would maintain their Emacs mappings:
	   C-c, C-h, C-x, C-z.   C-a can be used to intoduce "normal" Emacs
	   keystrokes which would otherwise be interpreted as VI keystrokes.
	   This can be done either as a prefix, or as a toggle to temporarily
	   disable the VI-mode (probably a prefix is better: if you're going
	   to Emacs mode, why are you using VI-mode?).

	c) All other ASCII keystrokes would be mapped to appropriate
	   functions which would emulate their counterpart VI-function.
	   Thus, C-w would back-erase a word in Input Mode, and beep in Edit
	   Mode; "h" would self-insert in Input Mode, and char-left in Edit
	   Mode.  Slight differences in emulation will affect whether or not 
	   macros are to be supported, and predefined ":map" commands from
	   ".exrc".

	d) The use of ESC as a Meta key would only occur in Edit Mode, thus
	   allowing Emacs Meta-key extensions, such as M-x;
	   in Input Mode, it would cause a shift to Edit Mode; 
	   in Command Mode, it acts as a CR.

	e) C-g would act heuristically: if a C-x or M-x sequence is being
	   entered, it would abort it and return to the previous mode; if
	   in Command Mode, and no keystroke sequence was in progress, then
	   execute as the ^G function in VI (really unecessary, since the
	   buffer status line contains the same info; but comforting to
	   accustomed VI users); in Input Mode, it would self-insert.
	
Remember, all of this is to make it as easy as possible to bring VI users
into the Emacs fold.  I'm convinced that once they start using Emacs on a
daily basis, along with a facile VI-mode, they won't go back to VI.
On its own merits, a VI-mode for Emacs experts would also be useful; I,
myself, prefer the shorter keystrokes and the "modality" of VI editing.

If there is some reason why a VI-mode doesn't exist (and I've missed the boat),
please let me know;  though I've installed Emacs twice, implemented some
simple fuctions, and am very impressed with Emacs, I'm essentially new to 
it and still learning a lot.

Thanks, in advance.

Alan K. Stebbens      (aks@acc-sb-unix.ARPA, aks@mimsy.umd.edu)

-- 

Alan Stebbens
     UUCP:  ..seismo!umcp-cs!aks
     ARPA:  aks@maryland