VI - Interface

Interface

vi is a modal editor: it operates in either insert mode (where typed text becomes part of the document) or normal mode (where keystrokes are interpreted as commands that control the edit session). For example, typing i while in normal mode switches the editor to insert mode, but typing i again at this point places an "i" character in the document. From insert mode, pressing the escape key switches the editor back to normal mode. A perceived advantage of vi's separation of text entry and command modes is that both text editing and command operations can be performed without requiring the removal of the user's hands from the home row. As non-modal editors usually have to reserve all keys with letters and symbols for the printing of characters, any special commands for actions other than adding text to the buffer must be assigned to keys which do not produce characters, such as function keys, or combinations of modifier keys such as Ctrl, and Alt with regular keys. Vi has the advantage that most ordinary keys are connected to some kind of command for positioning, altering text, searching and so forth, either singly or in key combinations. Many commands can be touch typed without the use of ⇧ Shift,Ctrl or Alt. Other types of editors generally require the user to move their hands from the home row when touch typing:

  • To use a mouse to select text, commands, or menu items in a GUI editor.
  • To the arrow keys or editing functions (Home / End or Function Keys).
  • To invoke commands using modifier keys in conjunction with the standard typewriter keys.

For instance, replacing a word is cwreplacement textEscape which is a combination of two independent commands (change and word-motion) together with a transition into and out of insert mode. Text between the cursor position and the end of the word is overwritten by the replacement text. The operation can be repeated at some other location by typing ., the effect being that the word starting that location will be replaced with the same replacement text.

Read more about this topic:  Vi