Manual Page Result
0
Command: vi | Section: 1 | Source: UNIX v10 | File: vi.1
VI(1) General Commands Manual VI(1)
NAME
ex, edit, vi - text editor
SYNOPSIS
ex [ option ... ] file ...
edit [ option ... ] file ...
vi [ option ... ] file ...
DESCRIPTION
Ex is elaborated from ed(1). Vi is the display editing aspect of ex;
edit is a simplified subset of ex. The editors work on several files
simultaneously. Vi gets the terminal type from environment variable
TERM.
The options are:
-r file
Recover the file after a crash in the editor. If no file is
specified, list all saved files.
-l Lisp indent mode; give special meaning to editor commands
()[]{}.
-wn Default window size is n lines.
-x Edit encrypted files; a key will be prompted for.
-R Read only; no files will be changed.
+cmd Execute the specified ex command upon entering the editor.
The editors begin in `command mode'. An ESC character typed in command
mode cancels the command. The commands a A c C i I o O R s S enter in-
put mode, where arbitrary text may be entered. ESC or interrupt re-
turns to command mode. The commands : / ? ! take input from the last
line of the screen, which is ended by a newline, or canceled by an in-
terrupt.
A number preceding commands z G | specifies a line. A number before
almost any other command causes it to be repeated.
In the following summary of vi commands ^ means the `control' key.
Commands so marked work in input mode; others work in command mode.
File manipulation :w write back changes :w file write file :w!
file overwrite file :q quit :q! quit, discarding changes :e
file edit file :e! reedit, discarding changes :e + file edit,
starting at end :e + startingat line n :sh run shell, then return
:! cmd run shell command :n edit next file argument : ex-cmd do
editor command
Positioning in file ^F forward screen ^B backward screen
^D down half screen ^U up half screen G to specified
line (end default) / pat next line matching pat ? pat previous
line matching n repeat last \ or ? /pat/_ n nth line after or
before pat ( beginning of sentence ) end of sentence
{ beginning of paragraph } end of paragraph % find
matching (){}
Adjusting the screen ^L clear and redraw ^R retype, elimi-
nate @ lines z redraw, current line at window z- ... at
bottom z. ... at center /pat/z- pat line at bottom z n use
n-line window ^E scroll down one line ^Y scroll up one line
Marking and returning `` move cursor to previous context
'' ... at first nonwhite in m x mark position with letter x
` x move cursor to mark ' x ... at first nonwhite
Line positioning H top line of screen L bottom line
M middle line + next line, at first nonwhite
- previous line, at first nonwhite <newline>same as +
j next line, same column k previous line, same column
Character positioning ^ first nonwhite (not CTRL) 0 be-
ginning of line $ end of line l forward h backward
^L ^H same as l h <space> same as l f x find x forward F
x find backward t x upto x forward T x back upto x
; repeat last f F t , opposite of ; | to specified
column % find matching (){}
Words, sentences, paragraphs w word forward b word back-
ward e end of word ) next sentence ( previous sen-
tence } next paragraph { previous paragraph
W blank-delimited word B backward to ... E to end
of ...
Corrections ^H erase last character ^W erase last word
erase your erase, same as ^H kill your kill, erase this line
\ quotes your erase or kill ESC return to command mode
^? interrupt, return to command mode ^D backtab over au-
toindent ^V quote nonprinting character
Insert and replace a append after cursor A append at end
of line i insert before cursor I insert before first non-
blank o open below line O open above r x replace one
character R text replace characters
Operators
Operators are followed by cursor motion and affect all text that would
have been moved over: dw deletes a word. Double the operator, e.g. dd,
to affect whole lines. d delete c change y yank
lines to buffer < left shift > right shift ! fil-
ter through command = Lisp indent
Miscellaneous operators C change rest of line (c$)
D delete rest of line (d$) s substitute characters (cd)
S substitute lines (cc) J join lines x delete
characters (dl) X ... before cursor (dh) Y yank lines
(yy)
Yank and put p put buffer after cursor P put buffer be-
fore cursor " x p put from buffer x x y yank to buffer x x
d delete to buffer x
Undo, redo, retrieve u undo last change U restore current
line . repeat last change " n p retrieve n-th last delete
Special ex commands
Ex understands most ed commands, plus the commands indicated with : in
the vi summary, plus the following, shown with their shortest possible
spellings: abbrev args copy map mark next number preserve put read re-
cover rewind set shell source stop unabbrev undo unmap version visual
xit yank z window < lshift > rshift ^D scroll The set command controls
various options; shows the list.
EXAMPLES
<-v^-> arrow keys move the cursor
hjkl same as arrow keys
itext<ESC>
insert text
cwnew<ESC>
change word to new
3dw delete 3 words
ZZ exit, saving changes
/text<newline>
search for text
^U ^D scroll up or down
FILES
recover command
preserve command
describes capabilities of terminals
editor startup file
editor temporary
named buffer temporary
preservation directory
SEE ALSO
ed(1), sam(9.1), sed(1)
W. Joy and M. Horton, `An Introduction to Display Editing with Vi', in
Unix Programmer's Manual, Seventh Edition, Virtual VAX-11 Version,
1980, Vol 2C (Berkeley)
VI(1)