Vi Quick Reference Template

ADVERTISEMENT

Vi Quick Reference
MOVEMENT
(lines - ends at <CR>; sentence - ends at puncuation-space; section - ends at <EOF>)
By Character
Marking Position on Screen
mp
mark current position as p (a..z)
k
`p
move to mark position p
'p
move to first non-whitespace on line w/mark p
hjkl
h
l
Miscellaneous Movement
j
fm
forward to character m
Fm
backward to character m
By Line
tm
forward to character before m
nG
to line n
Tm
backward to character after m
0, $
first, last position on line
w
move to next word (stops at puncuation)
^
_
first non-whitespace char on line
W
move to next word (skips punctuation)
or
+, -
first character on next, prev line
b
move to previous word (stops at punctuation)
B
move to previous word (skips punctuation)
e
end of word (puncuation not part of word)
By Screen
E
end of word (punctuation part of word)
^F, ^B
scroll foward, back one full screen
), (
next, previous sentence
^D, ^U
scroll forward, back half a screen
]], [[
next, previous section
^E, ^Y
show one more line at bottom, top
}, {
next, previous paragraph
L
go to the bottom of the screen
z↵ ↵
%
goto matching parenthesis () {} []
position line with cursor at top
z.
position line with cursor at middle
z-
position line with cursor at
EDITING TEXT
Entering Text
Searching and Replacing
a
append after cursor
/w
search forward for w
A
$a
append at end of line
?w
search backward for w
or
i
insert before cursor
/w/+n search forward for w and move down n lines
I
_i
insert at beginning of line
n
repeat search (forward)
or
o
open line below cursor
N
repeat search (backward)
O
open line above cursor
cm
change text (m is movement)
:s/old/new
replace next occurence of old with new
:s/old/new/g
replace all occurences on the line
:x,ys/old/new/g
replace all ocurrences from line x to y
Cut, Copy, Paste (Working w/Buffers)
:%s/old/new/g
replace all occurrences in file
dm
delete (m is movement)
:%s/old/new/gc same as above, with confirmation
dd
delete line
D
d$
delete to end of line
or
Miscellaneous
x
delete char under cursor
X
delete char before cursor
n>m
indent n lines (m is movement)
ym
yank to buffer (m is movement)
n<m
un-indent left n lines (m is movement)
yy
Y
yank to buffer current line
.
repeat last command
or
p
paste from buffer after cursor
U
undo changes on current line
P
paste from buffer before cursor
u
undo last command
“bdd
cut line into named buffer b (a..z)
J
join end of line with next line (at <cr>)
“bp
paste from named buffer b
:rf
insert text from external file f
^G
show status

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go