VI Tutorial - Lesson 4 - Organization of VI

The VI editor is a sophisticated editor with a wide range of commands, yet the basic structure is simple. There are two modes of operation in VI, command mode and text input mode. Command mode is where you tell the editor what you want it to do. Text input mode is the portion of the editor where you key in material (text, data, or program code) that you want retained in the file. Text input mode can only be accessed from command mode. The person who is able to visualize and separate the two modes of operation will very quickly master the control of this editor. The two modes of operation are illustrated in the block diagram at the end of this section.

4.1 Command Mode

Command mode is the initial state encountered when VI is invoked from the UNIX shell. It is in this state that VI receives instructions on what action is required, such as:


bringing text to the screen: scrolling, searching, using goto
moving the cursor
transferring to text input mode
text insertion: append, insert, open, change, and replace
reading in another file
deleting (lines, words, or characters)
changing (lines, words, or characters)
copying or yanking (lines, words, or characters)
undoing previous command action
using named buffers
joining lines

It is important for the new user to realize that when the majority of VI commands are keyed in, the editor does not echo the command back on the screen; rather, it simply executes the response the command requires.

In general, the steps given below will be repeated again and again each editing session while in command mode:


  1. place text in terminal window
  2. position the cursor
  3. give editing command

After a short time of using the editor, these actions will become second nature to you and performance of them will be done without concentration.

Figure 4.1

4.2 Text Input Mode

Text input mode is the second side of the VI editor. It is in this mode that you will key in the majority of text into your file. To enter text input mode a user would type, while in command mode, the editing command to append (a, A), insert (i, I), open (o, O), change (c,C), or replace (R). Without the initial command being echoed to the screen, the immediate response is for VI to transfer into text input mode. The user may see the cursor jump to a new location depending on the command issued. While in text input mode, all subsequent keystrokes will be directly reflected in the file. The user may now key in as much information as desired; a single character, a chapter of a book, or more. The user leaves text input mode by depressing the "ESC" key. More information is provided on how to use the append, insert, open, change and replace commands in section 7.

Most editing sessions include moving back and forth between command mode and text input mode. For example, a user may decide to change a word in one sentence (text input mode), move to the end of the file (command mode), add many additional pages of text (text input mode), backup half a page (command mode), correct some typos (text input mode), move again (command mode), and then insert a sentence in the middle of an existing paragraph (text input mode). This sounds complex, but don't worry, it is much easier to do than to read about.

previous | MENU | next

Last modified: 2009/09/01 09:46:26.251000 GMT-4 by christopher.n.deckard.1
Created: 2007/11/06 14:24:30.993000 US/Eastern by brian.r.brinegar.1.


Search the Knowledge Base


Quick search results

    Admin Options: Edit this Document