Vi Editor Cheat Sheet

ADVERTISEMENT

Vi Editor Cheat Sheet
Movement Commands
Character
h, j, k, l
Left, down, up, right
Text
w, W, b, B
Forward, backward by word
e, E 
End of word
(, )
Beginning of next, previous sentence
{, }
Beginning of next, previous paragraph
[[, ]]
Beginning of next, previous section
Lines
0, $
First, last position of current line
^
First non­blank character of current line
+, -
First character of next, previous line
H
Top line of screen
M
Middle line of screen
L
Last line of screen
n H, n
L
Line n
 from top, bottom of screen
Scrolling
Scroll forward, backward one screen
[Ctrl]F, [Ctrl]B 
Scroll down, up one­half screen
[Ctrl]D, [Ctrl]U 
[Ctrl]E, [Ctrl]Y 
Show one more line at bottom, top of window
z[Enter]
Scroll until line with cursor is at top of screen
z.
Scroll until line with cursor is at middle of screen
z-
Scroll until line with cursor is at bottom of screen
Searches
/pattern
Search forward for pattern
?pattern
Search backward for pattern
n, N
Repeat last search in same, opposite direction
/, ?
Repeat previous search forward, backward
fx
search forward for character x in current line
Fx
search backward for character x in current line
tx
search forward for character before x in current line
Tx
search backward for character after x in current line
;
Repeat previous current­line search
,
Repeat previous current­line search in opposite direction
Line Number
Display current line number
[Ctrl]G
G
Move to line number n
n
G
Move to last line in file
:n
move to line number n
Marking Position
mx
Mark current position as x
`x
Move cursor to x
``
Return to previous mark or context
'x
Move to beginning of line containing mark x
''
Return to beggining of line containing previous mark
Editing Commands
Insert
i, a
Insert text before, after cursor
I, A
Insert text at beginning, end of line
o, O
Open new line for text below, above cursor
Change
r
Replace with next typed characer

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go
Page of 2