

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


%^ vi^ filename Make sure terminal setup is correct (
% set term=vt
%^ vi^ -R
filename^ invoke vi in read only mode
:wq^
exit vi, saving changes :q!^
quit vi, without saving changes
%^ vi^ -r
filename^ recover file after system crash %^ vi^ -r
list all recoverable files
.exrc^
file containing ex commands to beexecuted upon startup EXINIT^
environment variable containing vicommands to be executed upon startup
h^ (or backspace)
move left one character j^
move down one line k^
move up one line l^ (or space)
move right one character Arrow keys may also be used
go to first line nG^
go to^ nth line G^
go to last line ^^
go to beginning of line $^
go to end of line
w^
go forward one word b^
go backward one word
Ctrl-f^
scroll forward one screen Ctrl-b^
scroll backward one screen Ctrl-d^
scroll down one half screen Ctrl-u^
scroll up one half screen
The following commands place you in insert mode:^ i^
insert text before cursor a^
append text after cursor I^
insert text at beginning of line A^
append text at end of line o^
start adding text in new line belowpresent line O^
start adding text in new line abovepresent line Use Escape to return to command mode
rchar^
substitute
char^ for character under cursor R^
overwrite old text (end with Esc) w^
change current word to new word (endwith Esc)
:set wrapmargin=
x Sets right margin to
x, automatic word wrap
Deleting, Copying, and Pasting TextDeleting Text Searches and Substitution
x^
delete character at cursor dd^
delete line ndd^
delete^ n^ lines ndw^
delete^ n^ words d$^
delete to end of line d^^
delete to beginning of line dG^
delete to end of file d1G^
delete to beginning of file
yy^
yank current line into buffer nyy^
yank^ n^ lines into buffer yw^
yank word nyw^
yank^ n^ words
p^
put most recently deleted or yankedcharacters or words after cursor; put linesbelow current line P^
put most recently deleted or yankedcharacters or words before cursor; putlines above current line
/string
search forward for
string
?string
search backward for
string
n^
repeat search N^
repeat search in opposite direction
:g/string/command
execute^ command
on lines containing string :v/string/command
execute^ command
on lines not containing string
:x,ys/oldstring/newstring/flags Substitutes
newstring
for^ oldstring
in line range
x,y.
flags^ (optional):^ c^
wait for confirmation (
y^ or^ n)
g^
replace all occurrences within specifiedlines (default is to replace only firstoccurrence) Range specifiers:^.^
current line $^
last line %^
entire file
Searches and Substitution (cont.)Special Characters Miscellaneous Commands
[ccc]
matches any specified character [^ccc]^
matches any character except thosespecified [c1-c2]
matches any character in range ^^
matches beginning of line $^
matches end of line
.^
matches any one character *^
matches zero or more occurrences ofprevious character .*^
matches any number of characters
:set ignorecase
disable case sensitivity :set noic
enable case sensitivity
command
execute
command :sh^
invoke subshell; use the
exit^ command to return to vi :r !command
insert output of
command
below current line
u^
undo last change U^
undo recent changes made to current line
repeat last command that made anediting change
:r
filename
insert
filename
below current line
join next line to current line
Ctrl-g^
display current line number and numberof lines in file :set number
display line numbers :set nonumber
remove displayed line numbers
Ctrl-l^
refresh screen