next up previous contents
Next: Basic Concepts and Terminology Up: Guide to VI and Previous: Foreword

Introduction to vi

The most useful standard text editor is vi , that is found on each UNIX system with the same features. With vi we can scroll the page, move the cursor, delete lines, insert characters, and more.

The following report is intended as a guide to vi usage and addresses people with a basic UNIX knowledge. vi belongs to the editor class that works by context, i.e. command behaviour depends on editing mode, basically command mode and editing mode. Command mode applies to specific actions such as deleting text, while text is typed when insert/append mode is entered by the appropriate editing command; editing mode is exited by <escape>.

As all UNIX tools vi is case sensitive. Commands are usually one character long and the same character may have different meaning depending on context. One important feature of vi is the capability to interact with the shell in any moment and to switch back and forth to ex to make use of a more complete editing environment.

The following documentation describes the complete set of vi and ex commands in tabular form with examples for the most complex situations.

vi supports compound commands in a way similar to option specification in UNIX. If a command acts on a character or a line, prefixing the command with a number expands the action to the next n elements:

x delete one char
10x delete 10 chars

In the same way different commands when typed in sequence produce a combined action, thus:

x delete one char
p put from local buffer
xp transpose char
Y cut line
Yp duplicate line

N.B. Note that compound commands are executed by vi sequentially by item, therefore item ordering is meaningful.

Examples:

$G set cursor at BOL of last line
G$ set cursor at EOL of last line

In the first example we ask vi to set the cursor at the end of the current line (command $) and then to go to the last line in file (command G), the result is the same achieved typing only G.
In the second example we ask vi to go the first character of last line in the file and then to go to line end.


next up previous contents
Next: Basic Concepts and Terminology Up: Guide to VI and Previous: Foreword
Marisa Luvisetto
2000-12-20