VI(1HAS) | User Commands | VI(1HAS) |
vi, view, vedit - screen-oriented (visual) display editor based on ex
/usr/bin/vi [-| -s] [-l] [-L] [-R] [-r [filename]] [-S]
[-t tag] [-v] [-V] [-x] [-wn] [-C]
[+command | -c command] filename...
/usr/bin/view [-| -s] [-l] [-L] [-R] [-r [filename]] [-S]
[-t tag] [-v] [-V] [-x] [-wn] [-C]
[+command | -c command] filename...
/usr/bin/vedit [-| -s] [-l] [-L] [-R] [-r [filename]] [-S]
[-t tag] [-v] [-V] [-x] [-wn] [-C]
[+command | -c command] filename...
/usr/xpg4/bin/vi [-| -s] [-l] [-L] [-R] [-r [filename]]
[-S] [-t tag] [-v] [-V] [-x] [-wn] [-C]
[+command | -c command] filename...
/usr/xpg4/bin/view [-| -s] [-l] [-L] [-R] [-r [filename]]
[-S] [-t tag] [-v] [-V] [-x] [-wn] [-C]
[+command | -c command] filename...
/usr/xpg4/bin/vedit [-| -s] [-l] [-L] [-R] [-r [filename]]
[-S] [-t tag] [-v] [-V] [-x] [-wn] [-C]
[+command | -c command] filename...
/usr/xpg6/bin/vi [-| -s] [-l] [-L] [-R] [-r [filename]]
[-S] [-t tag] [-v] [-V] [-x] [-wn] [-C]
[+command | -c command] filename...
/usr/xpg6/bin/view [-| -s] [-l] [-L] [-R] [-r [filename]]
[-S] [-t tag] [-v] [-V] [-x] [-wn] [-C]
[+command | -c command] filename...
/usr/xpg6/bin/vedit [-| -s] [-l] [-L] [-R] [-r [filename]]
[-S] [-t tag] [-v] [-V] [-x] [-wn] [-C]
[+command | -c command] filename...
The vi (visual) utility is a display-oriented text editor based on an underlying line editor ex. It is possible to use the command mode of ex from within vi and to use the command mode of vi from within ex. The visual commands are described on this manual page; how to set options (like automatically numbering lines and automatically starting a new output line when you type carriage return) and all ex line editor commands are described on the ex(1) manual page.
When using vi, changes you make to the file are reflected in what you see on your terminal screen. The position of the cursor on the screen indicates the position within the file.
The view invocation is the same as vi except that the readonly flag is set.
The vedit invocation is intended for beginners. It is the same as vi except that the report flag is set to 1, the showmode and novice flags are set, and magic is turned off. These defaults make it easier to learn how to use vi.
The following options are supported:
The following invocation options are interpreted by vi (previously documented options are discussed under NOTES):
− | -s
-C
-l
-L
-r filename
-R
-S
-t tag
-v
-V
-wn
-x
-command | -c command
If both the -t tag and the -c command options are given, the -t tag option is processed first. That is, the file containing tag is selected by -t and then the command is executed.
The following operands are supported:
filename
The vi command modes are summarized in this section.
Command
Input
a A i I o O c C s S R
Arbitrary text can then be entered. Input mode is normally terminated with the ESC character, or, abnormally, with an interrupt.
Last line
In the descriptions, CR stands for carriage return and ESC stands for the escape key.
←, →
down-arrow
up-arrow
h j k l
itextESC
cwnewESC
easESC
x
dw
dd
3dd
u
ZZ
:q!CR
/textCR
^U ^D
:cmdCR
Numbers can be typed as a prefix to some commands. They are interpreted in one of these ways:
line/column number
scroll amount
repeat effect
ESC
DEL
ZZ
:wCR
:w!CR
:qCR
:q!CR
:e nameCR
:e!CR
:e + nameCR
:e +nCR
:e #CR
:e! #CR
:w nameCR
:w! nameCR
:shCR
:!cmdCR
:nCR
:n argsCR
^G
:ta tagCR
In general, any ex or ed command (such as substitute or global) can be typed, preceded by a colon and followed by a carriage return.
F
^B
^D
^U
nG
/pat
?pat
n
N
/pat/+n
?pat?−n
]]
[[
(
)
{
}
%
^L
^R
zCR
z−CR
z.CR
/pat/z−CR
zn.CR
^E
^Y
``
a´a´
mx
`x
a´x
H
L
M
+
−
CR
down-arrow
or j
up-arrow
or k
^
0
$
l or →
h or ←
^H
space
fx
Fx
tx
Tx
;
,
n|
%
w
b
e
)
}
(
{
W
B
E
^H
^W
erase
kill
\
ESC
Control−C
^D
^^D
0^D
^V
a
A
i
I
o
O
rx
RtextESC
Operators are followed by a cursor motion and affect all text that would have been moved over. For example, since w moves over a word, dw deletes the word that would be moved over. Double the operator, for example dd, to affect whole lines.
d
c
y
<
>
!
C
D
s
S
J
x
X
Y
Put inserts the text most recently deleted or yanked; however, if a buffer is named (using the ASCII lower-case letters a - z), the text in that buffer is put instead.
3yy
3yl
p
P
"xp
"xy
"xd
u
U
.
"dp
See largefile(7) for the description of the behavior of vi and view when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
See environ(7) for descriptions of the following environment variables that affect the execution of vi: LANG, LC_ALL, LC_COLLATE, LC_CTYPE, LC_TIME, LC_MESSAGES, NLSPATH, PATH, SHELL, and TERM.
COLUMNS
EXINIT
LINES
/var/tmp
/usr/share/lib/terminfo/?/*
/usr/lib/.COREterm/?/*
See attributes(7) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
CSI | Not enabled |
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
CSI | Enabled |
Interface Stability | Standard |
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
CSI | Enabled |
Interface Stability | Standard |
Intro(1), ctags(1), ed(1), edit(1), ex(1), attributes(7), environ(7), largefile(7), standards(7)
Solaris Advanced User's Guide
vi and ex were developed by The University of California, Berkeley California, Computer Science Division, Department of Electrical Engineering and Computer Science.
Two options, although they continue to be supported, have been replaced in the documentation by options that follow the Command Syntax Standard (see Intro(1)). An -r option that is not followed with an option-argument has been replaced by -L and +command has been replaced by -c command.
The message file too large to recover with -r option, which is seen when a file is loaded, indicates that the file can be edited and saved successfully, but if the editing session is lost, recovery of the file with the -r option is not possible.
The editing environment defaults to certain configuration options. When an editing session is initiated, vi attempts to read the EXINIT environment variable. If it exists, the editor uses the values defined in EXINIT; otherwise the values set in $HOME/.exrc are used. If $HOME/.exrc does not exist, the default values are used.
To use a copy of .exrc located in the current directory other than $HOME, set the exrc option in EXINIT or $HOME/.exrc. Options set in EXINIT can be turned off in a local .exrc only if exrc is set in EXINIT or $HOME/.exrc. In order to be used, .exrc in $HOME or the current directory must fulfill these conditions:
Tampering with entries in /usr/share/lib/terminfo/?/* or /usr/share/lib/terminfo/?/* (for example, changing or removing an entry) can affect programs such as vi that expect the entry to be present and correct. In particular, removing the "dumb" terminal can cause unexpected problems.
Software tabs using ^T work only immediately after the autoindent.
Left and right shifts on intelligent terminals do not make use of insert and delete character operations in the terminal.
Loading an alternate malloc() library using the environment variable LD_PRELOAD can cause problems for /usr/bin/vi.
The vi utility currently has the following limitations:
If a longer line is found, Line too long is displayed in the status line.
If a larger temporary file is needed, Tmp file too large is displayed in the status line.
May 16, 2007 | OmniOS |