Skip Navigation Links | |
Exit Print View | |
man pages section 1: User Commands Oracle Solaris 11.1 Information Library |
- screen-oriented (visual) display editor based on ex
/usr/bin/vi [-| -s] [-l] [-L] [-R] [-r [filename]] [-S] [-t tag] [-v] [-V] [-wn] [+command | -c command] filename...
/usr/bin/view [-| -s] [-l] [-L] [-R] [-r [filename]] [-S] [-t tag] [-v] [-V] [-wn] [+command | -c command] filename...
/usr/bin/vedit [-| -s] [-l] [-L] [-R] [-r [filename]] [-S] [-t tag] [-v] [-V] [-wn] [+command | -c command] filename...
/usr/xpg4/bin/vi [-| -s] [-l] [-L] [-R] [-r [filename]] [-S] [-t tag] [-v] [-V] [-wn] [+command | -c command] filename...
/usr/xpg4/bin/view [-| -s] [-l] [-L] [-R] [-r [filename]] [-S] [-t tag] [-v] [-V] [-wn] [+command | -c command] filename...
/usr/xpg4/bin/vedit [-| -s] [-l] [-L] [-R] [-r [filename]] [-S] [-t tag] [-v] [-V] [-wn] [+command | -c command] filename...
/usr/xpg6/bin/vi [-| -s] [-l] [-L] [-R] [-r [filename]] [-S] [-t tag] [-v] [-V] [-wn] [+command | -c command] filename...
/usr/xpg6/bin/view [-| -s] [-l] [-L] [-R] [-r [filename]] [-S] [-t tag] [-v] [-V] [-wn] [+command | -c command] filename...
/usr/xpg6/bin/vedit [-| -s] [-l] [-L] [-R] [-r [filename]] [-S] [-t tag] [-v] [-V] [-wn] [+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 supporrted:
The following invocation options are interpreted by vi (previously documented options are discussed under NOTES):
Suppresses all interactive user feedback. This is useful when processing editor scripts.
Sets up for editing LISP programs.
Lists the name of all files saved as the result of an editor or system crash.
Edits filename after an editor or system crash. (Recovers the version of filename that was in the buffer when the crash occurred.)
Readonly mode. The readonly flag is set, preventing accidental overwriting of the file.
This option is used in conjunction with the -t tag option to tell vi that the tags file can not be sorted and that, if the binary search (which relies on a sorted tags file) for tag fails to find it, the much slower linear search should also be done. Since the linear search is slow, users of large tags files should ensure that the tags files are sorted rather than use this flag. Creation of tags files normally produces sorted tags files. See ctags(1) for more information on tags files.
Edits the file containing tag and position the editor at its definition. It is an error to specify more than one -t option.
Starts up in display editing state, using vi. You can achieve the same effect by typing the vi command itself.
Verbose. When ex commands are read by means of standard input, the input is echoed to standard error. This can be useful when processing ex commands within shell scripts.
Sets the default window size to n. This is useful when using the editor over a slow speed line.
Begins editing by executing the specified editor command (usually a search or positioning command).
If both the -t tag and the -c command options are given, the -t tag optionis processed first. That is, the file containing tag is selected by -t and then the command is executed.
The following operands are supported:
A file to be edited.
The vi command modes are summarized in this section.
Normal and initial mode. Other modes return to command mode upon completion. ESC (escape) is used to cancel a partial command.
Entered by setting any of the following options:
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.
Reading input for : / ? or !. Terminate by typing a carriage return. An interrupt cancels termination.
In the descriptions, CR stands for carriage return and ESC stands for the escape key.
arrow keys move the cursor
same as arrow keys
insert text
change word to new
pluralize word (end of word; append s; escape from input state)
delete a character
delete a word
delete a line
delete 3 lines
undo previous change
exit vi, saving changes
quit, discarding changes
search for text
scroll up or down
any ex or ed command
Numbers can be typed as a prefix to some commands. They are interpreted in one of these ways:
z G |
^D ^U
most of the rest
end insert or incomplete command
(delete or rubout) interrupts
if file modified, write and exit; otherwise, exit
write back changes
forced write, if permission originally not valid
quit
quit, discard changes
edit file name
reedit, discard changes
edit, starting at end
edit, starting at line n
edit alternate file
edit alternate file, discard changes
write file name
overwrite file name
run shell, then return
run cmd, then return
edit next file in arglist
specify new arglist
show current file and line
position cursor to tag
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.
forward screen
backward screen
scroll down half screen
scroll up half screen
go to the beginning of the specified line (end default), where n is a line number
next line matching pat
previous line matching pat
repeat last / or ? command
reverse last / or ? command
nth line after pat
nth line before pat
next section/function
previous section/function
beginning of sentence
end of sentence
beginning of paragraph
end of paragraph
find matching ( ) or { }
clear and redraw window
clear and redraw window if ^L is → key
redraw screen with current line at top of window
redraw screen with current line at bottom of window
redraw screen with current line at center of window
move pat line to bottom of window
use n-line window
scroll window down one line
scroll window up one line
move cursor to previous context
move cursor to first non-white space in line
mark current position with the ASCII lower-case letter x
move cursor to mark x
move cursor to first non-white space in line marked by x
top line on screen
last line on screen
middle line on screen
next line, at first non-white space character
previous line, at first non-white space character
return, same as +
next line, same column
previous line, same column
first non-white space character
beginning of line
end of line
forward
backward
same as ← (backspace)
same as → (space bar)
find next x
find previous x
move to character following the next x
move to character following the previous x
repeat last f, F, t, or T
repeat inverse of last f, F, t, or T
move to column n
find matching ( ) or { }
forward a word
back a word
end of word
to next sentence
to next paragraph
back a sentence
back a paragraph
forward a blank-delimited word
back a blank-delimited word
end of a blank-delimited word
erase last character (backspace)
erase last word
your erase character, same as ^H (backspace)
your kill character, erase this line of input
quotes your erase and kill characters
ends insertion, back to command mode
interrupt, suspends insert mode
backtab one character; reset left margin of autoindent
caret (^) followed by control-d (^D); backtab to beginning of line; do not reset left margin of autoindent
backtab to beginning of line; reset left margin of autoindent
quote non-printable character
append after cursor
append at end of line
insert before cursor
insert before first non-blank
open line below
open line above
replace single character with x
replace characters
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.
delete
change
yank lines to buffer
left shift
right shift
filter through command
change rest of line (c$)
delete rest of line (d$)
substitute characters (cl)
substitute lines (cc)
join lines
delete characters (dl)
delete characters before cursor dh)
yank lines (yy)
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.
yank 3 lines
yank 3 characters
put back text after cursor
put back text before cursor
put from buffer x
yank to buffer x
delete into buffer x
undo last change
restore current line
repeat last change
retrieve d'th last delete
See largefile(5) for the description of the behavior of vi and view when encountering files greater than or equal to 2 Gbyte ( 231 bytes).
See environ(5) 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.
Override the system-selected horizontal screen size.
Determine a list of ex commands that are executed on editor start-up, before reading the first file. The list can contain multiple commands by separating them using a vertical-line (|) character.
Override the system-selected vertical screen size, used as the number of lines in a screenful and the vertical screen size in visual mode.
default directory where temporary work files are placed; it can be changed using the directory option (see the ex(1) command)
compiled terminal description database
subset of compiled terminal description database
See attributes(5) for descriptions of the following attributes:
|
|
|
Intro(1), ctags(1), ed(1), edit(1), ex(1), attributes(5), environ(5), largefile(5), standards(5)
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:
It must exist.
It must be owned by the same userid as the real userid of the process, or the process has appropriate privileges.
It is not writable by anyone other than the owner.
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:
Lines, including the trailing NEWLINE character, can contain no more than 4096 bytes.
If a longer line is found, Line too long is displayed in the status line.
The editor's temporary work file can be no larger than 128Mb.
If a larger temporary file is needed, Tmp file too large is displayed in the status line.