vi(1)vi(1)NAME
vi, view, vedit - screen-oriented (visual) text editor
SYNOPSIS
tag] size] command] [file]...
UNIX Standard Synopsis
command] tag] size] [file]...
Obsolescent Options
command] tag] size] [file]...
tag] size] command] [file]...
tag] size] command] [file]...
Remarks
The program names and are separate personalities of the same program.
This manpage describes the behavior of the personality.
DESCRIPTION
The (visual) program is a display-oriented text editor that is based on
the underlying line editor (see ex(1)). It is possible to switch back
and forth between the two and to execute commands from within The line-
editor commands and the editor options are described in ex(1). Only
the visual mode commands are described here.
The program is identical to except that the editor option is set (see
ex(1)).
The program is somewhat friendlier for beginners and casual users. The
editor option is set to and the and editor options are set.
In the terminal screen acts as a window into a memory copy of the file
being edited. Changes made to the file copy are reflected in the
screen display. The position of the cursor on the screen indicates the
position within the file copy.
The environment variable must specify a terminal type that is defined
in the database (see terminfo(4)). Otherwise, a message is displayed
and the line-editor is invoked.
As with editor initialization scripts can be placed in the environment
variable or in the file in the current or home directory.
Options
recognizes the following command-line options:
Suppress all interactive-user feedback. This is useful when
editor commands are taken from scripts.
Set the
editor option (see ex(1)). Provides indents appropriate
for code. The and commands in are modified to function
with source code.
Recover the specified
files after an editor or system crash. If no file is
specified, a list of all saved files is printed. You
must be the owner of the saved file in order to recover
it (superuser cannot recover files owned by other users).
Set the
editor option to prevent overwriting a file inadvertently
(see ex(1)).
Execute the
tag command to load and position a predefined file. See
the command and the editor option in ex(1).
Invoke visual mode
Useful with it has no effect on
Set verbose mode.
Editor commands are displayed as they are executed when
input from a file or a source file (see the command in
ex(1)).
Set the value of the
editor option to size. If size is omitted, it defaults
to
Set encryption mode.
You are prompted for a key to allow for the creation or
editing of an encrypted file. This command makes an edu‐
cated guess to determine whether text read in is
encrypted or not. The temporary buffer file is encrypted
also, using a transformed version of the key typed in for
the option (see the command in ex(1)).
Encryption option. Same as the
option, except that all text read in is assumed to have
been encrypted. (Under UNIX Standard only, see stan‐
dards(5))
(Obsolescent)
Begin editing by executing the specified command-mode
commands. As with the normal command-line entries, the
option-argument can consist of multiple commands sepa‐
rated by vertical-line commands (|). The use of commands
that enter input mode in this manner produces undefined
results. file Specify the file or files to be edited.
If more than one file is specified, they are processed in
the order given. If the option is also specified, the
files are read from the recovery area.
(Under UNIX Standard only, see standards(5)) If both the and (or the
obsolescent options are given, the will be processed first, that is,
the file containing the tag is selected by and then the command is exe‐
cuted.
When invoked, is in is initiated by several commands used to insert or
change text.
In input mode, ESC (escape) is used to leave input mode; however, two
consecutive ESC characters are required to leave input mode if the edi‐
tor option is set (see ex(1)).
In command mode, ESC is used to cancel a partial command; the terminal
bell sounds if the editor is not in input mode and there is no par‐
tially entered command.
ESC a "bottom line" command (see below).
The last (bottom) line of the screen is used to echo the input for
search commands and commands and system commands It is also used to
report errors or print other messages.
The receipt of during text input or during the input of a command on
the bottom line terminates the input (or cancels the command) and
returns the editor to command mode. During command mode, causes the
bell to be sounded. In general the bell indicates an error (such as an
unrecognized key).
Lines displayed on the screen containing only a indicate that the last
line above them is the last line of the file (the lines are past the
end of the file). Terminals with limited local intelligence might dis‐
play lines on the screen marked with an These indicate space on the
screen not corresponding to lines in the file. (These lines can be
removed by entering a forcing the editor to retype the screen without
these holes.)
If the system crashes or aborts due to an internal error or unexpected
signal, attempts to preserve the buffer if any unwritten changes were
made. Use the command line option to retrieve the saved changes.
The text editor supports the signal, and redraws the screen in response
to window-size changes.
Command Summary
Most commands accept a preceding number as an argument, either to give
a size or position (for display or movement commands), or as a repeat
count (for commands that change text). For simplicity, this optional
argument is referred to as count when its effect is described.
The following operators can be followed by a movement command to spec‐
ify an extent of text to be affected: and The region specified begins
at the current cursor position and ends just prior to the cursor posi‐
tion indicated by the move. If the command operates on lines only, all
the lines that fall partly or wholly within this region are affected.
Otherwise the exact marked region is affected.
In the following description, control characters are indicated in the
form which represents Whitespace is defined to be the characters space,
tab, and alternative space. Alternative space is the first character
of the item described in langinfo(5) for the language specified by the
environment variable (see environ(5)).
Unless otherwise specified, the commands are interpreted in command
mode and have no special effect in input mode.
Scroll backward to display the previous window of text.
A preceding count specifies the number of windows to
go back. Two lines of overlap are kept if possible.
Scroll forward a half-window of text.
A preceding count gives the number of (logical)
lines to scroll, and is remembered for future and
commands.
(input mode)
Backs up over the indentation provided by or to the
next multiple of spaces. Whitespace inserted by at
other than the beginning of a line cannot be backed
over using A preceding removes all indentation for
the current and subsequent input lines of the cur‐
rent input mode until new indentation is established
by inserting leading whitespace, either by direct
input or by using
Scroll forward one line, leaving the cursor where it is if pos‐
sible.
Scroll forward to display the window of text following the cur‐
rent one.
A preceding count specifies the number of windows to
advance. Two lines of overlap are kept if possible.
(Under UNIX Standard only, see standards(5) The cur‐
rent line is displayed and the cursor is moved to
the first nonblank character of the current line or
the first character if the line is a blank line.
Print the current file name and other information,
including the number of lines and the current posi‐
tion (equivalent to the command
Move one space to the left (stops at the left margin).
A preceding count specifies the number of spaces to
back up. (Same as
(input mode)
Move the cursor left to the previous input character
without erasing it from the screen. The character
is deleted from the saved text.
Move the cursor down one line in the same column, if possible.
A preceding count specifies the number of lines to
move down. (Same as and
Clear and redraw the screen.
Use when the screen is scrambled for any reason.
Move to the first nonwhitespace character in the next line.
A preceding count specifies the number of lines to
advance.
Same as and
Move the cursor up one line in the same column.
A preceding count specifies the number of lines to
move up (same as
Redraw the current screen, eliminating the false lines marked
with
(which do not correspond to actual lines in the
file).
Pop the tag stack.
See the command in ex(1).
(input mode)
Insert whitespace. If at the beginning of the line,
this inserted space can only be backed over using
Scroll up a half-window of text.
A preceding count gives the number of (logical)
lines to scroll, and is remembered for future and
commands.
In input mode,
quotes the next character to permit the insertion of
special characters (including ESC) into the file.
In input mode,
backs up one word; the deleted characters remain on
the display.
Scroll backward one line, leaving the cursor where it is, if
possible.
Cancel a partially formed command;
sounds the bell if there is no partially formed com‐
mand.
In input mode, terminates input mode. However, two
consecutive ESC characters are required to terminate
input mode if the editor option is set (see ex(1)).
When entering a command on the bottom line of the
screen command line or search pattern with or termi‐
nate input and execute command.
On many terminals, can be entered by pressing the
ESC or ESCAPE key.
Exit and enter ex command mode. If in input mode, termi‐
nate the input first.
Take the word at or after the cursor as a tag and execute the
editor command (see ex(1)).
Return to the previous file (equivalent to
space Move one space to the right (stops at the end of the
line). A preceding count specifies the number of
spaces to go forward (same as
erase Erase, where erase is the user-designated erase
character (see stty(1)). Same as
kill Kill, where kill is the user-designated kill charac‐
ter (see stty(1)). In input mode, kill backs up to
the beginning of the current input line without
erasing the line from the screen display.
susp Suspend the editor session and return to the calling
shell, where susp is the user-designated process-
control suspend character (see stty(1)). See ex(1)
for more information on the editor command.
An operator that passes specified lines from the buffer
as standard input to the specified system command,
and replaces those lines with the standard output
from the command. The is followed by a movement
command specifying the lines to be passed (lines
from the current position to the end of the move‐
ment) and then the command (terminated as usual by a
return). A preceding count is passed on to the
movement command after
Doubling and preceding it by count causes that many
lines, starting with the current line, to be passed.
Use to precede a named buffer specification.
There are named buffers through in which the editor
places deleted text. The named buffers through are
available to the user for saving deleted or yanked
text; see also below.
Move to the end of the current line.
A preceding count specifies the number of lines to
advance (for example, causes the cursor to advance
to the end of the next line).
Move to the parenthesis or brace that matches
the parenthesis or brace at the current cursor posi‐
tion.
Same as the ex command (that is, repeats the previous command).
When followed by a
returns to the previous context, placing the cursor
at the beginning of the line. (The previous context
is set whenever a nonrelative move is made.) When
followed by a letter returns to the line marked with
that letter (see the command), at the first non‐
whitespace character in the line.
When used with an operator such as to specify an
extent of text, the operation takes place over com‐
plete lines (see also
When followed by a
returns to the previous context, placing the cursor
at the character position marked (the previous con‐
text is set whenever a nonrelative move is made).
When followed by a letter returns to the line marked
with that letter (see the command), at the character
position marked.
When used with an operator such as to specify an
extent of text, the operation takes place from the
exact marked place to the current position within
the line (see also
Back up to the previous section boundary.
A section is defined by the value of the option.
Lines that start with a form feed or also stop
If the option is set, the cursor stops at each at
the beginning of a line.
Move forward to a section boundary (see
Move to the first nonwhitespace position on the current line.
Move backward to the beginning of a sentence.
A sentence ends at a or followed by either the end
of a line or by two spaces. Any number of closing
and characters can appear between the or and the
spaces or end of line. If a count is specified, the
cursor moves back the specified number of sentences.
If the option is set, the cursor moves to the begin‐
ning of a s-expression. Sentences also begin at
paragraph and section boundaries (see and
Move forward to the beginning of a sentence.
If a count is specified, the cursor advances the
specified number of sentences (see
Move back to the beginning of the preceding paragraph.
A paragraph is defined by the value of the option.
A completely empty line and a section boundary (see
above) are also interpreted as the beginning of a
paragraph. If a count is specified, the cursor
moves backward the specified number of paragraphs.
Move forward to the beginning of the next paragraph.
If a count is specified, the cursor advances the
specified number of paragraphs (see
Requires a preceding
count; the cursor moves to the specified column of
the current line (if possible).
Move to the first nonwhitespace character in the next line.
If a count is specified, the cursor advances the
specified number of lines (same as
The comma performs the reverse action of the last or command
issued, by searching in the opposite direction on
the current line. If a count is specified, the cur‐
sor repeats the search the specified number of
times.
The hyphen character
moves the cursor to the first nonwhitespace charac‐
ter in the previous line. If a count is specified,
the cursor moves back the specified number of times.
The underscore character
moves the cursor to the first nonwhitespace charac‐
ter in the current line. If a count is specified,
the cursor advances the specified number of lines,
with the current line being counted as the first
line; no count or a count of 1 specifies the current
line.
Repeat the last command that changed the buffer.
If a count is specified, the command is repeated the
specified number of times.
Read a string from the last line on the screen,
interpret it as a regular expression, and scan for‐
ward for the next occurrence of a matching string.
The search begins when the user types a carriage
return to terminate the pattern; the search can be
terminated by sending (or the user-designated inter‐
rupt character).
When used with an operator to specify an extent of
text, the defined region begins with the current
cursor position and ends at the beginning of the
matched string. Entire lines can be specified by
giving an offset from the matched line (by using a
closing followed by a or ).
Move to the first character on the current line (the
is not interpreted as a command when preceded by a
nonzero digit).
The colon character
begins an command. The and the entered command are
echoed on the bottom line; the command is executed
when the user types a carriage return.
Repeat the last single character find using
or If a count is specified, the search is repeated
the specified number of times.
An operator that shifts lines to the left by one
The can be followed by a move to specify lines. A
preceding count is passed through to the move com‐
mand.
When repeated shifts the current line (or count
lines starting at the current one).
An operator that shifts lines right one
(see
If the option is set, reindents the specified lines, as if
they were typed in with and set. can be preceded by
a count to indicate how many lines to process, or
followed by a move command for the same purpose.
Scan backwards, the reverse of
(see
Execute the commands stored in the named
buffer. Be careful not to include a <return> char‐
acter at the end of the buffer contents unless the
<return> is part of the command stream. Commands to
be executed in ex mode should be preceded by a colon
The tilde switches the case of the character under the cursor
(if it is a letter), then moves one character to the
right, stopping at the end of the line). A preced‐
ing count specifies how many characters in the cur‐
rent line are switched.
Append at the end of line (same as
Back up one word, where a word is any nonblank sequence,
placing the cursor at the beginning of the word. If
a count is specified, the cursor moves back the
specified number of words.
Change the rest of the text on the current line (same as
Delete the rest of the text on the current line (same as
Move forward to the end of a word, where a word is any nonblank
sequence.
If a count is specified, the cursor advances the
specified number of words.
Must be followed by a single character;
scans backwards in the current line, searching for
that character and moving the cursor to it, if
found. If a count is specified, the search is
repeated the specified number of times.
Go to the line number given as preceding argument,
or the end of the file if no preceding count is
given.
Move the cursor to the top line on the screen.
If a count is given, the cursor moves to count num‐
ber of lines from the top of the screen. The cursor
is placed on the first nonwhitespace character on
the line. If used as the target of an operator,
entire lines are affected.
Insert at the beginning of a line (same as
followed by
Join the current line with the next one, supplying appropriate
whitespace:
one space between words, two spaces after a period,
and no spaces at all if the first character of the
next line is a closing parenthesis A preceding count
causes the specified number of lines to be joined,
instead of just two.
Move the cursor to the first nonwhitespace character of
the last line on the screen. If a count is given,
the cursor moves to count number of lines from the
bottom of the screen. When used with an operator,
entire lines are affected.
Move the cursor to the middle line on the screen,
at the first nonwhitespace position on the line.
Scan for the next match of the last pattern given to
or but in the opposite direction; this is the
reverse of
Open a new line above the current line and enter input mode.
Put back (replace) the last deleted or yanked text before/above
the cursor.
Entire lines of text are returned above the cursor
if entire lines were deleted or yanked. Otherwise,
the text is inserted just before the cursor.
(Under UNIX Standard only, see standards(5)) In this
case, the cursor is moved to last column position of
the inserted characters.
If is preceded by a named buffer specification (x),
the contents of that buffer are retrieved instead.
Exit and enter command mode.
Replace characters on the screen with characters entered,
until the input is terminated with ESC.
Change entire lines (same as
A preceding count changes the specified number of
lines.
Must be followed by a single character;
scan backwards in the current line for that charac‐
ter, and, if found, place the cursor just after that
character. A count is equivalent to repeating the
search the specified number of times.
Restore the current line to its state before the cursor was last
moved to it.
(Under UNIX Standard only, see standards(5)) The
cursor position is set to the column position 1 or
to the position indicated by the previous line if
the is set.
Move forward to the beginning of a word in the current line,
where a word is a sequence of nonblank characters.
If the current position is at the beginning of a
word, the current position is within a bigword or
the character at that position cannot be a part of a
bigword, the current position shall move to the
first character of the next bigword. If no subse‐
quent bigword exists on the current line, the cur‐
rent position shall move to the first character of
the first bigword on the first following line that
contains the bigword. For this command, an empty or
blank line is considered to contain exactly one big‐
word. The current line is set to the line containing
the bigword selected and the current position is set
to the first character of the bigword selected. A
preceding count specifies the number of words to
advance.
Delete the character before the cursor.
A preceding count repeats the effect, but only char‐
acters on the current line are deleted.
Place (yank) a copy of the current line into the unnamed buffer
(same as
If a count is specified, count lines are copied to
the buffer. If the is preceded by a buffer name,
the lines are copied to the named buffer.
Exit the editor, writing out the buffer if it was changed since
the last write (same as the command Note that if the
last write was to a different file and no changes
have occurred since, the editor exits without writ‐
ing out the buffer.
Enter input mode, appending the entered text
after the current cursor position. A preceding
count causes the inserted text to be replicated the
specified number of times, but only if the inserted
text is all on one line.
Back up to the previous beginning of a word in the current line.
A word is a sequence of alphanumerics or a sequence
of special characters. A preceding count repeats
the effect.
Must be followed by a movement command.
Delete the specified region of text, and enter input
mode to replace deleted text with new text. If more
than part of a single line is affected, the deleted
text is saved in the numeric buffers. If only part
of the current line is affected, the last character
deleted is marked with a A preceding count passes
that value through to the move command. If the com‐
mand is the entire current line is changed.
Must be followed by a movement command.
Delete the specified region of text. If more than
part of a line is affected, the text is saved in the
numeric buffers. A preceding count passes that
value through to the move command. If the command
is the entire current line is deleted.
Move forward to the end of the next word, defined as for
A preceding count repeats the effect.
Must be followed by a single character;
scan the rest of the current line for that charac‐
ter, and moves the cursor to it if found. A preced‐
ing count repeats the action that many times.
Move the cursor one character to the left (same as
A preceding count repeats the effect.
Enter input mode, inserting the entered text before the cursor
(see
Move the cursor one line down in the same column (same as
and
Move the cursor one line up (same as
Move the cursor one character to the right (same as
Mark the current position of the cursor.
is a lowercase letter, that is used with the and
commands to refer to the marked line or line posi‐
tion.
Repeat the last
or scanning commands.
Open a line below the current line and enter input mode;
otherwise like
Put text after/below the cursor;
otherwise like
Must be followed by a single character;
the character under the cursor is replaced by the
specified one. (The new character can be a new-
line.) If is preceded by a count, count characters
are replaced by the specified character.
Delete the single character under the cursor and enter input
mode;
the entered text replaces the deleted character. A
preceding count specifies how many characters on the
current line are changed. The last character being
changed is marked with a as for
Must be followed by a single character;
scan the remainder of the line for that character.
The cursor moves to the column prior to the charac‐
ter if the character is found. A preceding count is
equivalent to repeating the search count times.
Reverse the last change made to the current buffer.
If repeated, alternates between these two states;
thus is its own inverse. When used after an inser‐
tion of text on more than one line, the lines are
saved in the numerically named buffers.
Move forward to the beginning of the next word
(where word is defined as in A preceding count spec‐
ifies how many words the cursor advances.
Delete the single character under the cursor.
When is preceded by a count, deletes the specified
number of characters forward from the cursor posi‐
tion, but only on the current line.
Must be followed by a movement command;
the specified text is copied (yanked) into the
unnamed temporary buffer. If preceded by a named
buffer specification, the text is placed in that
buffer also. If the command is the entire current
line is yanked.
Redraw the screen with the current line placed
as specified by the following options: specifies the
top of the screen, the center of the screen, and the
bottom of the screen. The commands and are similar
to and respectively. However, and do not attempt to
maintain two lines of overlap. A count after the
and before the following character to specifies the
number of lines displayed in the redrawn screen. A
count before the gives the number of the line to use
as the reference line instead of the default current
line.
Keyboard Editing Keys
At initialization, the editor automatically maps some terminal keyboard
editing keys to equivalent visual mode commands. These mappings are
only established for keys that are listed in the following table and
defined in the terminfo(4) database as valid for the current terminal
(as specified by the environment variable).
Both command and input mode mappings are created (see the command in
ex(1)). With the exception of the keys, which simply toggle input mode
on and off, the input mode mappings exit input mode, perform the same
action as the command mode mapping, and then reenter input mode.
On certain terminals, the character sequence sent by a keyboard editing
key, which is then mapped to a visual mode command, can be the same
character sequence a user might enter to perform another command or set
of commands. This is most likely to happen with the input mode map‐
pings; therefore, on these terminals, the input mode mappings are dis‐
abled by default. Users can override the disabling and enabling of
both the command and input mode keyboard editing key mappings by set‐
ting the and editor options as appropriate (see ex(1)). The and editor
options are alternative methods of addressing this problem.
terminfo command input map
entry mode map mode map name description
───────────────────────────────────────────────────────────────────
key_ic i ^[ inschar insert char
key_eic i ^[ inschar end insert char
key_up k ^[ka up arrow up
key_down j ^[ja down arrow down
key_left h ^[ha left arrow left
key_right l ^[la right arrow right
key_home H ^[Ha home arrow home
key_il o^[ ^[o^[a insline insert line
key_dl dd ^[dda delline delete line
key_clear ^L ^[^La clear clear screen
key_eol d$ ^[d$a clreol clear line
key_sf ^E ^[^Ea scrollf scroll down
key_dc x ^[xa delchar delete char
key_npage ^F ^[^Fa npage next page
key_ppage ^B ^[^Ba ppage previous page
key_sr ^Y ^[^Ya sr scroll up
key_eos dG ^[dGa clreos clear to end of screen
───────────────────────────────────────────────────────────────────
EXTERNAL INFLUENCES
For information about the UNIX standard environment, see standards(5).
International codes and environment variables are explained in this
section.
Environment Variables
overrides the system-selected horizontal screen size.
overrides the system-selected vertical screen size, used as the number
of lines in a screenful and the vertical screen size in visual mode.
is a variable that shall be interpreted as the preferred command-line
interpreter for use in and other commands with an operand of the form
For the command the program shall be invoked with the two arguments and
If this variable is null or not set, the utility shall be used.
is a variable that shall be interpreted as the name of the terminal
type. If this variable is unset or null, an unspecified default termi‐
nal type shall be used.
determines the search path for the shell command specified in the edi‐
tor commands, and
determines a list of ex commands that will be executed on editor
startup, before reading the first file. The list can contain multiple
commands by separating them using a vertical line (|) character.
determines a pathname of a directory that will be searched for an edi‐
tor startup file named
This variable shall determine the locale to be used to override any
values for locale categories specified by the setting of or any envi‐
ronment variables beginning with
determines the locale that should be used to affect the format and con‐
tents of diagnostic messages written to standard error and informative
messages written to standard output.
determines the collating sequence used in evaluating regular expres‐
sions and in processing the tags file.
determines the interpretation of text as single and/or multi-byte char‐
acters, the classification of characters as uppercase or lowercase let‐
ters, the shifting of letters between uppercase and lowercase, and the
characters matched by character class expressions in regular expres‐
sions.
determines the language in which messages are displayed.
specifies options determining how text for right-to-left languages is
stored in input and output files. See environ(5).
If or is not specified in the environment or is set to the empty
string, the value of is used as a default for each unspecified or empty
variable. If is not specified or is set to the empty string, a default
of "C" (see lang(5)) is used instead of If any internationalization
variable contains an invalid setting, the editor behaves as if all
internationalization variables are set to "C". See environ(5).
International Code Set Support
Single- and multi-byte character code sets are supported.
WARNINGS
See also the section in ex(1).
Program Limits
places the following limits on files being edited. characters includ‐
ing 2-3 bytes for overhead. Thus, a line length up to 4092 characters
should cause no problem.
If you load a file that contain lines longer than the specified limit,
the lines are truncated to the stated maximum length. Saving the file
will write the truncated version over the original file, thus overwrit‐
ing the original lines completely.
Attempting to create lines longer than the allowable maximum for the
editor produces a error message. The maximum file length of 234,239
lines is silently enforced.
· 256 characters per global command list.
· 128 characters in a file name in or mode. On short-file-name
HP-UX systems, the maximum file name length is 14 characters.
· 128 characters in a previous insert/delete buffer.
· 100 characters in a shell-escape command.
· 63 characters in a string-valued option command).
· 30 characters in a program tag name.
· 32 or fewer macros defined by command.
· 512 or fewer characters total in combined macros.
Do not use the option to edit unencrypted files. The option is meant to
be used only on files that are already encrypted. If the option is used
on files which are not yet encrypted, a write in the edit session is
likely to corrupt the file.
AUTHOR
was developed by the University of California, Berkeley. The 16-bit
extensions to are based in part on software of the Toshiba Corporation.
SEE ALSOctags(1), ed(1), ex(1), stty(1), write(1), terminfo(4), environ(5),
lang(5), regexp(5), standards(5).
Benjamin/Cummings Publishing Company, Inc., ISBN 0-8053-4460-8, HP part
number 97005-90015.
STANDARDS CONFORMANCEvi(1)