San Diego State University

Technical Briefs

ROHAN help Files

----------------------------------------------------------------------

vi

vi is the visual editor for UNIX machines. It differs from the VAX/VMS editor in that vi is a moded editor: you are either in command mode or you are in input mode. In command mode, each keystroke is assumed to be a command; in input mode, each keystroke is put into the file unless it is backspace (the funny X key inside the diamond on vt220s) or ESCAPE. ESCAPE terminates the input mode, and puts you back to command mode. If you don't know what mode you're in, press ESCAPE until your terminal beeps. Then you are in command mode. In command mode, the most useful commands are:

i[string]ESCAPE
goes into input mode until you press ESCAPE
a[string]ESCAPE
like "i", but appends (after instead of before)
x
deletes (x's out) one character
dw
delete word (up to next blank)
dd
delete whole line
o
open a line up after the current line and go to input mode
r
replace the char under the cursor with one next character
A
append to end of line (good for putting in forgotten semicolons)
0
NOTE: zero, not "oh" -- go to beginning of this line
$
go to end of this line
G
go to last line in file
:1
go to first line in file

For further help, try vi summary

------------------------------------------------------------

Starting commands

vi myfile
edit the file called myfile
vi +n myfile
edit the file myfile at line n
vi + myfile
edit the file myfile at the end
vi -r
list saved files
vi -r myfile
recover file myfile that aborted during editing
vi file1 file2 ...
edit the specified files in sequence
vi -t tag
start editing at tag

Return to Top of document


Text Insert Mode commands

^D
back up over one level of indentation if autoindent set
0^D
kill autoindent
^^D
kill autoindent on this line, restore it on next
^H
delete last input character
^T
if in autoindent mode, insert one shiftwidth blank or tab
^W
delete last input word
ESC
return to command mode from insertion mode (escape key)
INT
interrupt insertion, return to command mode (usually ^C)
erase
delete last character entered (usually delete key or ^H)
kill
delete input on this line (your kill key)
^Q
quote non-printing character
\
escapes ^H, your erase and kill

Return to Top of document


File commands

:w
write changes to current file
:w myfile
save changes to myfile
:w! file1
overwrite existing file file1
:wq
write and quit
:q
quit if no changes were made
:q!
quit and don't save changes
:e other
edit another file called other
:e!
reedit, discard changes
:e +n
edit, starting at line n
:e + file1
edit file1 starting at the end
:e #
edit an alternate file
:sh
run shell, then return
:!cmd
run cmd, then return
:n
edit the next file in the argument list to vi
:n args
specify new argument list args
:f
show current file and line (same as ^G)
:ta tag to tag
file entry tag (same as ^])

Return to Top of document

----------------------------------------------------------------------


BACK ROHAN Help Index | Academic Computing Handouts, Manuals, and Help Files