The VI/Vedit editors
This description is based on the manual page for the vi editor.
- The vi and vedit commands
- Edits files with a full-screen display.
- Syntax
{ vi | vedit } [ -c Subcommand]
[ -l ] [ -R ] [ -tTag] [ -v]
[ -wNumber] [ -yNumber] [ -r [File]]
[ + [Subcommand]] [File ... ]
- Description
- The vi command starts a full-screen editor based on the underlying ex editor. Therefore,
ex subcommands can be used within the vi editor.
- The vedit command starts a version of the vi editor intended for beginners.
- In the vedit editor, the report option is set to 1, the showmode option is set, and the
novice option is set, making it a line editor.
- You start the vi editor by specifying the name of the file or files to be edited. If you supply more than
one File on the command line, the vi editor edits each file in the specified order.
Execution of the vi editor
- Since the vi editor is a full-screen editor, you can edit text on a screen-by-screen basis.
- The vi editor makes a copy of the file you are editing in an edit buffer, and the contents of the file are not
changed until you save the changes.
- The position of the cursor on the display screen indicates its position within the file, and the subcommands
affect the file at the cursor position.
vi
Editor Limitations
The following list provides the maximum limits of the vi editor. These counts assume single-byte characters.
- 2048 characters per line
- 256 characters per global command list
- 128 characters in the previously inserted and deleted text
- 128 characters in a shell escape command
- 128 characters in a string-valued option
- 30 characters in a tag name
- 1,048,560 lines of 2048 characters per line silently enforced
- 128 map macros with 2048 characters total.
Editing Modes
The vi editor operates in the following modes:
- command mode
- When you start the vi editor, it is in command mode.
- You can enter any subcommand except those designated for use only in the text input mode.
- The vi editor returns to command mode when subcommands and other modes end.
- Press the Esc key to cancel a partial subcommand.
- text input mode
- You use the vi editor in this mode when you add text. Enter text input mode with any of the following
subcommands:
- a
subcommand, A subcommand, i subcommand, I subcommand,
o subcommand, O subcommand, cx subcommands (where x represents the scope of the
subcommand), C subcommand, s subcommand, S subcommand, and R
subcommand.
- After entering one of these subcommands, you can enter text into the editing buffer.
- To return to command mode, press the Esc key for normal exit or
- Press Interrupt (the Ctrl-C key sequence) to end abnormally.
- last line mode
- Subcommands with the prefix : (colon), / (slash), ? (question mark), ! (exclamation point), or !! read input on
a line displayed at the bottom of the screen.
- When you enter the initial character, the vi editor places the cursor at the bottom of the screen, where you
enter the remaining characters of the command.
- Press the Enter key to run the subcommand or Interrupt (the Ctrl-C key sequence) to cancel it.
- When !! is used, the cursor moves only after both exclamation points are entered. When you use : (colon)
to enter the last line mode, special meaning is given to the following characters when they are used before
commands that specify counts:
% All lines regardless of cursor position
$ Last line
. Current line.
Customizing the vi Editor
You can customize the vi editor by:
- Setting editor options
- Defining macros
- Mapping keys
- Setting abbreviations
vi General Subcommand Syntax
[Named_Buffer] [Operator] [Number] Object
- Note: Square brackets indicate optional items.
[Named_Buffer]
- Specifies a temporary text storage area.
[Operator]
- Specifies the subcommand or action; instructs the vi editor.
[Number]
- Is a whole decimal value that specifies either the extent of the action or a line address.
Object
- Specifies what to act on. This can be a text object (a character, word, sentence, paragraph, section, character
string) or a text position (a line, position in the current line, screen position).
Counts before Subcommands
You can put a number in front of many subcommands. The vi editor interprets this number in one of the following
ways:
- Go to the line specified by the Number parameter:
5G
10Z
- Go to the column specified by the Number parameter:
25|
- Scroll the number of lines up or down specified by the Number parameter:
10Ctrl-U
10Ctrl-D
- Note: In the last example, 10Ctrl-U or 10Ctrl-D means to type the number ten, then press the Ctrl-U (up) or
Ctrl-D (down) key sequence.
vi command syntax and semantics
Moving within a File
The subcommands for moving within a file enable you to move in the following ways:
Editing a File with the vi Editor
The subcommands for editing enable you to perform the following tasks:
Manipulating Files with the vi Editor
The subcommands for manipulating files allow you to do the tasks outlined in the following sections:
General Subcommands
The vi editor provides the subcommands described in the following sections:
Glossary Terms: command mode, current line, literal string, macro, mode, regular expression,
scroll, section.
Related Information: The view command, ex command, ed command, sed command, tvi command,
ctags command.