vi, vedit, view - Edits files with a full screen display
Normal Syntax
vi [-ls] [-R] | [-r] [-c subcommand] [-t tag] [-w number]
[-x] [-v] [+[subcommand]] [-] [file...]
Read-only Syntax [Toc] [Back]
view [-l] [-R] | [-r] [-t tag] [-c subcommand] [-w number]
[-x] [-v] [+[subcommand]] [-] [file...]
Novice Version Syntax [Toc] [Back]
vedit [-l] [-R] | [-r] [-t tag] [-w number] [-x] [-v] [-]
[file...]
The vi command is a display editor that is based on an
underlying line editor (ex).
Interfaces documented on this reference page conform to
industry standards as follows:
vi: XCU5.0
vedit: XCU5.0
view: XCU5.0
ex: XCU5.0
Refer to the standards(5) reference page for more information
about industry standards and associated tags.
Performs the specified ex subcommand before editing
begins.
This subcommand may actually consist of several
commands separated by vertical line (|) characters.
Indents appropriately for LISP code, and accepts
the (, ), {, }, [, and ] characters (parentheses,
braces, and brackets) as text rather than interpreting
them as vi subcommands. The LISP modifier
is active in open or visual modes. Recovers file
after an editor or system crash. If you do not
specify a file, vi displays a list of all saved
files. [Tru64 UNIX] Invokes vi in open mode.
(Silent mode.) Sets the readonly option to protect
the file against overwriting.
[Tru64 UNIX] This option is automatically invoked
if you use the view command. Edits the file containing
the tag and positions the editor at its
definition. To use this option, you must first
create a database of function names and their locations
using the ctags command. [Tru64
UNIX] Invokes the visual editor. When the -v
option is specified, an enlarged set of subcommands
is available, including screen editing and cursor
movement features. This option has no effect when
vi is specified, but is honored for compatibility
with historical conventions. Sets the default window
size to number. This is useful when you use
the editor over a low-speed line. [Tru64
UNIX] Prompts for an encryption key and then unencrypts
the file. If the file specified is not
encrypted or an incorrect key is entered, garbled
text is displayed. [Tru64 UNIX] Suppresses all
interactive user feedback. If you use this option,
file input/output errors do not generate an error
message. Performs the ex subcommand before editing
begins. If you do not specify subcommand, the cursor
is placed on the last line of the file. This
option is obsolescent.
This subcommand may actually consist of several
commands separated by vertical line (|) characters.
The file argument specifies the files to be edited. If
you supply more than one file on the command line, vi
edits each file in the order specified.
The ex editor subcommands can be used within the vi editor,
because vi is based on ex. The view command is a
read-only version of vi; the readonly option is set to
protect files during browsing. The vedit command is a
version of vi intended for beginners. In it, the report
option is set to 1, the showmode option is set, and the
novice option (making vedit a line editor, rather than a
screen editor) is set. (For more information on these
options, see Setting Options.)
When you use vi, changes you make to a file are reflected
on your display. The position of the cursor on the display
indicates its position within the file. The subcommands
affect the file at the cursor position.
[Tru64 UNIX] You can encrypt a file using the :X subcommand.
Ensure that you remember the encryption key because
an easy means to unencrypt a file does not exist. Only
the first 6 characters of a key are significant.
Limitations of the vi Editor [Toc] [Back]
The maximum limits of the vi editor are as follows: [Tru64
UNIX] 2048 bytes per line [Tru64 UNIX] 256 bytes per
global command list [Tru64 UNIX] 128 bytes in the previous
inserted and deleted text [Tru64 UNIX] 128 bytes in a
shell escape command [Tru64 UNIX] 128 bytes in a stringvalued
option [Tru64 UNIX] 100 bytes in a tag name [Tru64
UNIX] 128 map macros with 2048 bytes total.
Editing Modes [Toc] [Back]
The vi editor has the following operational modes: When
you start the vi editor, it is in Command mode. Any subcommand
can be entered from this mode, except commands
that can only be used in the Text Input mode (those subcommands
that make corrections during text insertion).
When subcommands and the other modes end, vi returns to
Command mode. Pressing the <Esc> key cancels a partial
subcommand. Entered by the a, A, i, I, o, O, cx (where x
represents the scope of the subcommand), C, s, S, and R
subcommands. After entering one of these commands, you can
enter text into the editing buffer at the current cursor
position. To return to Command mode, press <Esc> for normal
exit or press the Interrupt key sequence to end
abruptly. Some subcommands (those with the prefix :
(colon), / (slash), ? (question mark), or !!) read input
on a line displayed at the bottom of the screen. When you
enter the initial character, vi places the cursor at the
bottom of the screen, where you enter the remaining characters
of the command. Press <Return> to perform the subcommand
and enter the Interrupt key sequence to cancel it.
When !! is used, the cursor moves only after the
two exclamation points are entered. When : is
used, special meaning is given to the following
characters if used as counts before a command: All
lines, regardless of cursor position Last line Current
line
Setting Options [Toc] [Back]
The vi editor allows you to customize options so that you
can use the editor for a specific task. Use the set command
to set or change an option. To view the current setting
of all options, enter :set all while in vi Command
mode. To view the current setting of options that may be
set to a value, enter a line of the form :set option.
Some options are set to a string or a number value; other
options are simply turned on or off. To change an option
that is set to a value, enter a command in the form :set
option=value. To toggle an option that can be set to on or
off, enter a line of the form :set option to set it to on
or :set nooption to set it to off.
Options can be abbreviated in a set command. The following
table lists some of vi's options, along with abbreviations
and descriptions:
Option Abbreviation Description
[no]autoindent ai Indents automatically in
Text mode to the indentation
on the previous line
by using the spacing
between tab stops specified
by the shiftwidth
option. The default is
noai. To back the cursor
up to the previous tab
stop, type <Ctrl-d>. This
option is not in effect
for global commands.
[no]autoprint ap Prints the current line
after any command that
changes the editing
buffer. The default is ap.
This option applies only
to the last command in a
sequence of commands on a
single line, and is not in
effect for global commands.
[no]autowrite aw Writes the editing buffer
to the file automatically
before the :n, :ta, <Ctrla>,
and ! subcommands if
the editing buffer was
changed since the last
write command. The
default is noaw.
[no]beautify bf Prevents user from entering
control characters
(except for tab, newline,
and formfeed) in the editing
buffer during text
entry. The default is
nobf. This option does
apply to command input.
closepunct cp= The default is
cp='".,;)]}.
directory dir= Displays the directory
that contains the editing
buffer. The default is
dir=/var/tmp.
[no]edcompatible ed Retains global (g) and
confirms (c) subcommand
suffixes during multiple
substitutions and causes
the read (r) suffix to
work like the r subcommand.
The default is
noed.
[no]errorbells eb Precedes error messages
with an <Alert> character.
Setting this option off
(noeb) does not suppress
the alerting in visual
mode. The default is
noeb.
[no]exrc "! If not set, ignores any
file in the current directory
during initialization,
unless the current
directory is that named by
the HOME variable. The
default is noexrc.
[no]flash fl Uses visual flash rather
than audible bell. The
default is fl.
hardtabs ht= Tells vi the distance
between the hardware tab
stops on your display.
The default is ht=8.
[no]ignorecase ic Ignores the distinction
between uppercase and lowercase
while searching for
regular expressions. The
default is noic.
[no]lisp lisp Enters vi in LISP mode.
In this mode, vi appropriately
indents for LISP
code and the (, ), {, },
[[, and ]]. The default
is nolisp.
[no]list list Displays text with tabs
and the end of lines
marked. Tabs are displayed
as ^I and the end
of lines as $. The
default is nolist.
[no]magic magic Treats the characters [,
and * as special characters
in scans. In Off
mode, only the (, ), and $
characters retain special
meanings; however, special
meaning of other characters
can still be invoked
by preceding the character
with a \ (backslash). The
default is magic.
[no]mesg mesg Permits other users to use
the talk or write commands
to write to the terminal
when in visual mode. The
shell level mesg n command
takes precedence over the
mesg option. If a mesg y
command was issued before
vi (or ex) was started,
set nomesg can be used to
suppress message, but a
set mesg input can not
override a mesg n command.
The default is mesg.
[no]modeline modeline Runs an editor command
line if found in the first
five and the last five
lines of the file. An
editor command line may be
anywhere in a line. To be
recognized as a command
line, it must contain a
space or a tab followed by
the string ex: or vi:.
The command line is ended
by a second : (colon).
The editor tries to interpret
any data between the
first and second : as editor
commands. The default
is nomodeline.
[no]novice novice The default is nonovice.
[no]number nu Displays lines prefixed
with their line numbers.
The default is nonu.
[no]optimize opt Speeds up the operation of
terminals that do not have
cursor addressing. The
default is noopt.
paragraphs para= Defines macro names that
start paragraphs. The
default is para=IPLPPPQPP
LIpplpipnpbp. Single
letter nroff macros, such
as
must include the
space as a quoted
character if
respecifying a
paragraph.
partialcharacter pc= The default is pc=-.
[no]prompt prompt Prompts for command mode
input with a : (colon).
When not set, no prompt is
displayed. The default is
prompt.
readonly " Allows writing to a different
file. In addition,
the write can be forced by
using the ! (exclamation
point) character (see the
editor command write).
The default is off, unless
the file lacks write permission
or the -R option
is specified.
[no]redraw re Simulates a smart display
on a dumb display. The
default is nore.
[no]remap remap Enables following of map
keys. For example, if
remap is set, map u k map
r u causes r to map to k.
If noremap is set, r maps
to u. The default is
remap.
report report= Sets the number of repetitions
of a command before
a message is displayed.
For subcommands that can
produce a number of messages,
such as global subcommands,
the messages are
displayed when the command
is completed. The default
is report=5.
scroll scr= Sets the number of lines
to be scrolled when you
scroll the screen up or
down. The default scroll
is one-half the size of
the screen.
sections sect= Defines macro names that
start sections. The
default is
sect=NHSHH HUuhsh+c. Single
letter nroff macros,
such as
must include the
space as a quoted
character if
respecifying a
paragraph.
shell sh= Defines the shell for !
or :! commands. The
default is the value of
the SHELL environment
variable.
shiftwidth sw= Sets the distance for the
software tab stops used by
autoindent, the shift commands
(> and <), and the
text input commands
(<Ctrl-d> and <Ctrl-t>) to
allow the editor to indent
text and move back to a
previous indentation. The
default is sw=8.
[no]showmatch sm Shows the matching open
parenthesis ( or open
brace { as you type the
close parenthesis ) or
close brace }. The
default is nosm.
[no]showmode smd Displays mode indicator at
the bottom of the screen
when in the insert or
replace mode. The default
is nosmd.
[no]slowopen slow Postpones updating the
display during inserts.
The default is noslow.
[no]sourceany Allows the use of the
source command on a file
that a user does not own.
The default is
nosourceany.
tabstop ts= Sets the distance between
tab stops when a file is
displayed. The default is
ts=8.
taglength tl= Determines length of tag.
The default is tl=0.
[no]tags tag Specifies a list of possible
file names of tag
files. The default is
tag=tags /usr/lib/tags.
term term= Sets the kind of display
you are using. The
default is term=$TERM,
where $TERM is the value
of the TERM shell variable.
[no]terse terse Allows vi to display the
short form of messages.
The default is noterse.
[no]timeout to Sets a time limit of 2
seconds on entry of characters.
This limit allows
the characters in a macro
to be entered and processed
as separate characters
when timeout is set.
To resume use of the
macro, set notimeout. The
default is to.
ttytype tty= Same as term.
[no]warn warn Displays a warning message
before the ! subcommand
executes a shell command
if this is the first time
you issued a shell command
after a given set of
changes were made in the
editing buffer, but not
written to a file. The
default is warn.
window wi= Sets the number of lines
displayed in one window of
text. The default is
dependent on the baud rate
at which you are operating:
600 baud or less
/ 8 lines, 1200 baud
/ 16 lines, higher
speeds / full screen
minus 1.
wrapmargin wm= Sets the margin for automatic
wordwrapping from
one line to the next. A
value of wm=8, for example,
causes vi to wrap
additional characters to
the next line when the
cursor is 8 characters or
less from the right margin.
A value of 0 indicates
no wordwrapping. The
default is wm=0.
[no]wrapscan ws Allows string searches to
wrap from the end of the
editing buffer to the
beginning. The default is
ws.
wraptype wt= (For editing Japanese)
Controls wrapping of
Japanese words. Setting
wraptype=general causes
general-purpose wrap on
word breaks, where word
break is defined as
whitespace or space
between two nonASCII characters.
Setting wraptype=general
is a combination
of word and flexible.
Setting wraptype=word
causes wrap on words.
Setting wraptype=rigid
causes wrap on column and
before closing punctuation.
Setting wraptype=flexible
causes wrap
on column, but closing
punctuation may extend
past the margin. The
default is wt=word.
[no]writeany wa Turns off the checks usually
made before a write
command. The default is
nowa.
Defining Macros [Toc] [Back]
If you use a subcommand or sequence of subcommands frequently,
you can create a macro that issues the subcommand
or sequence when you call a macro. To create a macro,
enter the sequence of subcommands into an editing buffer
named with a letter of the alphabet. When used as buffer
names, lowercase ASCII letters a through z overlay the
contents of the buffer, while uppercase ASCII letters A
through Z append text to the previous contents of the
buffer, allowing the building of a macro piece by piece.
To invoke the macro, enter @x, where x is the letter name
of the buffer. Enter @@ to repeat the last macro you
invoked.
Mapping Keys [Toc] [Back]
You can use the map command to set a keystroke to a subcommand
or a sequence of subcommands. To set a key mapping,
enter :map key subcommand where key is the key to
which you want to assign a subcommand or sequence of subcommands
and subcommand is the subcommand or sequence of
subcommands. For example, to set @ to delete lines,
enter: :map @ dd
In this example, @ is the key to which the subcommand is
assigned and dd is the subcommand.
In the next example, a subcommand sequence is mapped to a
key: :map * {>}
The * (asterisk) is the key to which the subcommand
sequence is assigned and {>} is the subcommand sequence.
The { (open brace) moves the cursor to the beginning of
the paragraph and the > (right angle bracket) indents the
paragraph to the next shiftwidth.
To display the list of the current key mappings while you
are in Command mode, enter the :map command. You can also
remove a key mapping. To remove a key mapping, enter
:unmap string or :unmap! string where string is the
string used after the :map command to set the key and subcommand
sequence. For example, to remove key mapping for
the previous example, enter: :unmap *
If function keys are defined for your terminal, they can
be put in a map or unmap command by typing <Ctrl-v> then
pressing the desired key. In this way, function keys that
are unused during editing can be mapped to useful editing
subcommand sequences.
If the ! (exclamation point) character is appended to the
command name map (map!), the mapping is effective during
input mode rather than during visual mode.
Abbreviations [Toc] [Back]
You can define abbreviations for long phrases that you use
often. The vi editor then automatically expands these
abbreviations whenever you enter them in insert mode. Only
single-byte characters can appear in abbr_string;
abbr_string cannot contain Asian multibyte characters.
To define an abbreviation, enter: :abbr abbreviation
phrase
where abbreviation is the abbreviation you specify for the
longer text specified by phrase. For example, to specify
the abbreviation imho for the phrase In my humble opinion,
enter: :abbr imho In my humble opinion
Keeping a Customized Change [Toc] [Back]
When you customize vi from the vi command line, the customized
editor is in effect until you exit the editor. If
you want to reuse such things as option settings and key
mappings, you must put them in the file in your home
directory or define the EXINIT environment variable. The
vi editor processes the commands given in the EXINIT variable
or reads the file each time you invoke it. Here is an
example of an file:
set ai aw set wm=5 map @ dd
Users with both a file and an EXINIT environment variable
will find that the vi editor no longer reads the file.
This change was made to meet the specifications of XPG4.
The standard provides for an approximation of the old
behavior. A new variable, named exrc, is defined. When
this variable is set by the commands in the EXINIT environment
variable, the editor reads in the current directory
for additional startup commands. For example: setenv
EXINIT 'set ai terse magic bf wm=1 exrc'
[Tru64 UNIX] Additionally, the editor refuses to read the
file if its mode grants write permission to anyone other
than the owner; this restriction prevents certain security
breaches. No overt indication is given when such a
refusal occurs.
vi Character Sets
The collation sequence, as defined by the value of the
LC_COLLATE environment variable, defines the alphanumeric
set used by your system. This table affects the performance
of vi macros and subcommands.
The vi editor uses the collation sequence to distinguish
between a small word and a big word. A small word is
bounded by letters or numbers as defined in the collation
table. For example, isn't is two small words. The '
(apostrophe) is not a number or an alphabetic character,
and it bounds both the small word t and the small word
isn. A big word is bounded by spaces, tabs, or newline
indicators. For example, stop is a big word. For more
information, see the section Moving to Words.
Subcommand Syntax [Toc] [Back]
[named_buffer] [operator] [number] argument
Surrounding brackets indicate optional items. A temporary
text storage area. Specifies the subcommand or action;
instructs the vi editor. A whole decimal value that specifies
either the extent of the action or a line address.
The vi editor interprets this number in one of the following
ways: Go to line number: 5G 10z<Return> Go forward
number columns. 25<Space> Scroll number of lines:
10<Ctrl-d> 10<Ctrl-u> Delete number lines: 6dd The % means
all. To yank all lines: %y
(The preceding command replaces 1,$y.) Specifies
what to act on. This can be a text object (a character,
word, sentence, paragraph, section, or character
string) or a text position (a line, position
in the current line, or screen position).
Moving Within a File [Toc] [Back]
Enter the following subcommands in Command mode. You can
cancel an incomplete subcommand by pressing the <Esc> key.
Moves the cursor one character to the left. Moves the
cursor down one line, remaining in the same column. Moves
the cursor up one line, remaining in the same column.
Moves the cursor one character to the right.
Long lines: Lines over one screen width are
wrapped but not broken. When using the Up Arrow or
Page Up key, @ lines are added at the bottom of the
screen when too few physical lines are available to
display the complete line. The Down Arrow key
moves the entire line off the screen at once.
Character Positioning Within a Line [Toc] [Back]
Enter the following subcommands in Command mode. Moves
the cursor to the first nonspace character. Moves the
cursor to the beginning of the line. Moves the cursor to
the end of the line. Moves the cursor to the next x character.
Moves the cursor to the last x character. Moves
the cursor to one column before the next x character.
Moves the cursor to one column after the last x character.
Repeats the last f, F, t, or T subcommand. Repeats the
last f, F, t, or T subcommand in the opposite direction.
Moves the cursor to the specified column.
Moving to Words [Toc] [Back]
Enter the following subcommands in Command mode. Moves
the cursor to the next small word. Moves the cursor to
the previous small word. Moves the cursor to the end of
the next small word. Moves the cursor to the next big
word. Moves the cursor to the previous big word. Moves
the cursor to the end of the next big word.
Moving by Line Positioning [Toc] [Back]
Enter the following subcommands in Command mode. Moves to
the line number given as preceding argument, or the end of
the file if no preceding count is given. Moves the cursor
to the top line on the screen. Moves the cursor to the
last line on the screen. Moves the cursor to the middle
line on the screen. Moves the cursor to the next line, at
its first nonspace character. Moves the cursor to the
previous line, at its first nonspace character. Moves the
cursor to the next line, at its first nonspace character.
Moving to Sentences, Paragraphs, or Sections
Enter the following subcommands in Command mode. You can
cancel an incomplete subcommand by pressing the <Esc> key.
Places the cursor at the beginning of the previous sentence
(or the previous S-expression if you are in LISP
mode). Places the cursor at the beginning of the next
sentence (or the next S-expression if you are in LISP
mode). Places the cursor at the beginning of the previous
paragraph (or at the next list if you are in LISP mode).
Places the cursor at the beginning of the next paragraph,
at the next section if you are in C mode, or at the next
list if you are in LISP mode. Requires a count; the cursor
is placed in that column (if possible). Places the
cursor at the next section, or function if you are in LISP
mode. Places the cursor at the previous section, or function
if you are in LISP mode.
Paging and Scrolling [Toc] [Back]
Scrolls up (default 12 lines). Scrolls down (default 12
lines). Pages forward one screen. Pages backward one
screen. Scrolls the window up one line. Scrolls the window
down one line. Moves to the first non-white character
in the next line. A count specifies the number of lines
to go forward. Inserts shiftwidth white space in input
mode, if at the beginning of the line or preceded only by
white space. This inserted space can only be backed over
using <Ctrl-d>. Cancels a partially formed command;
sounds the bell if there is none.
In input mode, terminates input mode.
When entering a command on the bottom line of the
screen (ex command line or search pattern with / or
?), terminates input and executes command. Pages
up. Pages down.
Searching for Patterns [Toc] [Back]
The following commands allow you to search for patterns
within a file. Patterns can be regular expressions as
described for grep. Places the cursor at the next line
containing pattern. Repeats the last search for pattern
in the direction of the end of the file. Places the cursor
at the next previous line containing pattern. Repeats
the last search for pattern in the direction of the beginning
of the file. Repeats the last search for pattern in
the same direction. Repeats the last search for pattern
in the opposite direction. Places the cursor at the numberth
line after the line matching pattern. Places the
cursor at the numberth line before the line matching pattern.
Finds the parenthesis or brace that matches the one
at the current cursor position.
Marking and Returning [Toc] [Back]
Enter the following subcommands in Command mode. You can
cancel an incomplete subcommand by pressing the <Esc> key.
Moves the cursor to the same cursor position of the previous
current line. Moves the cursor to the beginning of
the previous current line. Marks the current position
with the letter specified by x. Moves the cursor to the
same cursor position of line marked x. Moves the cursor
to the beginning of the line marked x.
Adjusting the Screen [Toc] [Back]
Enter the following subcommands in Command mode. An
incomplete subcommand can be canceled by pressing the
<Esc> key. Clears and redraws the screen. Redraws the
screen and eliminates blank lines marked with a @.
Redraws the screen with the current line at the top of the
screen. Redraws the screen with the current line at the
bottom of the screen. Redraws the screen with the current
line at the center of the screen. Redraws the screen with
the line containing pattern at the top. Redraws the
screen with the line containing pattern at the top.
Redraws the screen with the line containing pattern at the
bottom. Redraws the screen with the line containing pattern
at the center. Makes the window number lines long.
Adding Text to a File--Text Input Mode [Toc] [Back]
The following subcommands are entered in Command mode and
bring the vi editor into Text Input mode to allow you to
add text to your file. End Text Input mode by pressing
the <Esc> key. Inserts text after the cursor. Adds text
to the end of the line. Inserts text before the cursor.
Inserts text before the first nonspace character in the
line. Adds an empty line below the current line. Adds an
empty line above the current line.
Changing Text While in Input Mode [Toc] [Back]
Use the following commands only while in Text Entry mode.
They have different meanings in Command mode. Erases the
last character. Erases the last small word. (For more
information about small words, see the section vi Character
Sets.) Quotes the Erase and Kill characters. Ends
insertion, back to Command mode. Interrupts, terminates
insert or <Ctrl-d>. Goes back to the previous autoindent
stop. Ends autoindent for this line only. Moves the cursor
back to the left margin. Quotes a nonprinting character.
Changing Text from Command Mode [Toc] [Back]
Use the following subcommands in Command mode. An incomplete
subcommand can be canceled by pressing the <Esc>
key. Changes the rest of the line (c$). Must be followed
by a movement command. Deletes the specified region of
text and enters input mode to replace it with the entered
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
to be deleted is marked with a $. A count is passed
through to the move command. If the command is cc, the
whole of the current line is changed. Changes a line.
Changes a word. Deletes the rest of the line (d$) and
puts it into the undo buffer. Must be followed by a movement
command. Deletes the specified region of text. If
more than part of a line is affected, the text is saved in
the numeric buffers. A count is passed through to the
move command. If the command is dd, the whole of the current
line is deleted. Deletes a line and puts it into the
undo buffer. Deletes a word and puts it into the undo
buffer. Joins lines. Replaces the current character with
the character specified by x. Overwrites characters.
Substitutes characters (cl). Substitutes lines (cc).
Undoes the previous change. Deletes a character. Deletes
characters before cursor (dh). Shifts one line to the
left. Shifts all lines from the cursor to the end of the
screen to the left. (The < character describes a range
upon which the L subcommand acts.) Shifts one line to the
right. Shifts all lines from the cursor to the end of the
screen to the right. (The > character describes a range
upon which the L subcommand acts.) Changes the letter at
the cursor to the opposite case.
Copying and Moving Text [Toc] [Back]
Use the following subcommands in Command mode. An incomplete
subcommand can be canceled by pressing <Esc>. Puts
back text in the undo buffer after (before) the cursor.
Puts back text from the buffer x after (before) the cursor.
You must precede the character x with a double
quote. Deletes object into the buffer x. You must precede
the character x with a double quote. Yanks object
into the undo buffer (for example, yw to yank a word).
Yanks object into buffer x. You must precede the character
x with a double quote. Places the line in the undo
buffer.
Restoring and Repeating Changes [Toc] [Back]
Use the following subcommands in Command mode. An incomplete
subcommand can be canceled by pressing the <Esc>
key. Undoes the last command. Restores the current line
if the cursor has not left the line since the last change.
Repeats the last change or increments the np command.
Note that this command is not meant for use with a
macro. Enter @@ to repeat a macro. Retrieves the
nth last delete of a complete line or block of
lines. You must precede the character n with a
double quote.
Saving Changes to a File [Toc] [Back]
Use the following subcommands in Command mode. An incomplete
subcommand can be canceled by pressing <Esc>. If
you are using these subcommands within the ex editor, do
not type the : (colon). Writes the editing buffer contents
to the original file. Writes the editing buffer
contents to the named file. Overwrites file with the
editing buffer contents. [Tru64 UNIX] Prompts you to
enter an encryption key. When you save the file, it is
written in encrypted form. For subsequent edits of the
encrypted file, use the -x option to display the file in
its unencrypted form.
Interrupting, Cancelling, and Exiting vi
Enters the ex editor in Command mode. Exits vi, saving
changes, if any were made. Quits vi. If you have changed
the contents of the editing buffer, vi displays a warning
message and does not quit. Quits vi, discarding the editing
buffer with no warning. Runs a shell. You can return
to vi by pressing <Ctrl-d>. Runs the file through the
specified shell command (causes no change to the file).
Runs command, then returns. Repeats the last :!command
command. Executes the shell command identified by command
and replaces the number of lines specified by n with the
output of command. If n is not specified, the default is
1. If command expects standard input, the lines specified
are used as input. (10!!sort sorts the next 10 lines.)
Works like n!!command, except that lines is a line address
(for example, !Gsort sorts the rest of the file). Interrupts
a subcommand.
Editing a Second File [Toc] [Back]
Enter the following subcommands in Command mode. An
incomplete subcommand can be canceled by pressing the
<Esc> key. Edits file. If you are using this subcommand
from the ex editor, do not type the : (colon). Reedits
the current file and discards all changes. Edits file,
starting at the end. Edits file, starting at the line
number. Edits the alternate file. The alternate file is
usually the previous current file name. However, if
changes are pending on the current file when a new file is
called, the new file becomes the alternate file. Reads
the file into the editing buffer by adding new lines below
the current line. If you are using this subcommand from
the ex editor, do not type the : (colon). Runs the shell
command identified by command and places its output in the
file by adding new lines below the current cursor position.
Using a Tags File [Toc] [Back]
The ctags command makes a tags file from the specified C,
Pascal, FORTRAN, yacc, lex, or LISP source files. A tags
file gives the locations of function and type definitions
in a group of files. To use the next three commands, you
must first create a database of function names and their
locations (called a tags file) using the ctags command.
Edits a file containing tag at the location of tag. If
the tag is in another file and the current file has been
changed (and noaw is set), a warning is posted. If you are
using this subcommand from the ex editor, do not type the
: (colon). Finds the word at the cursor in the tags file
then displays the proper file, placing the cursor at the
tag. If the tag is in the current file, moves cursor to
it. Same as :ta, but the tag is the word to the right of
the cursor. Returns to the file and line where the cursor
was positioned when <Ctrl-]> was entered.
Editing a List of Files [Toc] [Back]
Enter the following subcommands in Command mode. Edits
the next file in the list entered on the command line.
Specifies a new list of files to edit.
Displaying File Information [Toc] [Back]
[Tru64 UNIX] Enter the following subcommand in Command
mode to show the current file name, the current line number,
the number of lines in the file, and the percentage
of lines of the file that are before the cursor:
<Ctrl-g>
The following exit values are returned: Successful completion.
An error occurred.
The following actions are taken upon receipt of signals:
The current editor command is aborted and vi returns to
the command level and prompts for another command. The
screen is refreshed if in visual mode. If the current
buffer has changed since the last e or w command, vi
attempts to save the current file in a state such that it
can be recovered later by an ex -r or vi -r command.
ENVIRONMENT VARIABLES [Toc] [Back] The following environment variables affect the execution
of vi: Overrides the system-selected horizontal screen
size. Determines a list of ex commands to be executed at
startup before the first file is read. The list can
include multiple commands separated by a vertical line (|)
character. Determines the pathname of a directory
searched at startup for a file named Provides a default
value for the internationalization variables that are
unset or null. If LANG is unset or null, the corresponding
value from the default locale is used. If any of the
internationalization variables contain an invalid setting,
the utility behaves as if none of the variables had been
defined. If set to a non-empty string value, overrides
the values of all the other internationalization variables.
Determines the locale for the behavior of ranges,
equivalence classes, and multicharacter collating elements
within regular expressions. Determines the locale for the
interpretation of sequences of bytes of text data as characters
(for example, single-byte as opposed to multibyte
characters in arguments and input files), the behavior of
character classes within regular expressions, the classification
of characters as upper- or lower-case letters,
the case conversion of letters, and the detection of word
boundaries. Overrides the system-selected vertical screen
size, used as the number of lines in a screenful and the
vertical screen size in visual mode. Determines the
locale for the format and contents of diagnostic messages
written to standard error. Determines the location of
message catalogues for the processing of LC_MESSAGES.
Determines the search path for the shell command specified
in the editor commands shell, read and write and the
visual-mode command !. Determines the preferred commandline
interpreter for use in !, shell, read and other commands
with an operand of the form !string. For the shell
command the program will be invoked with the single argument
-i, for all others it will be invoked with the two
arguments -c and string. If this variable is null or not
set, the sh command will be used. Determines the name of
the terminal type. If this variable is unset or null, a
default terminal type that provides most capabilities is
used.
Commands: ctags(1), edit(1), ed(1), ex(1), grep(1),
mesg(1), nroff(1), sed(1)
Files: terminfo(4)
Environment: environ(5)
Standards: standards(5)
vi(1)
[ Back ] |