vi Command Reference

By | 2008-10-25

A table of commands used in the Unix-based vi editing program. Commands include moving the cursor, text insertion and deletion, screen commands, and change commands.

Moving the Cursor
hOne space to the left
jOne space to up
kOne space down
lOne space to the right
 Beginning of new line
Beginning of previous line
^Beginning of current line
$End of current line
 Forward one space
nGBeginning of line n
bBeginning of current word
wBeginning of next word
eEnd of current word
Control – eScroll forward
Control – bScroll backward
/patternFirst occurence of pattern
nNext occurence of pattern
NPrevious occurence of pattern
/Repeats last pattern search
Text Insertion and Deletion
aAppends text to the right of the cursor
AAppends text at the end of the line
iInserts text to the left of the cursor
IInserts text at the beginning of the line
oOpens a new line below the current line for text to be inserted
OOpens a new line above the current line for text to be inserted
xDeletes character at cursor position
XDeletes character left of cursor position
ddDeletes current line
dwDeletes current word
d)Deletes rest of sentence
D or d$Deletes from cursor to end of line
PPuts back text from the previous delete
rxReplaces selected character with x
uUndoes last change
URestores current line
:R myfileAppends file “myfile” to current file at current cursor position
DELOverwrites last character during text insertion
ESCStops text insertion, returns to command mode
Screen Commands
Control – IReprints current screen
Control – LExposes one more line at top of screen
Control – EExposes one more line at bottom of screen
Control – FPages forward one screen
Control – BPages back one screen
Control – DPages down half a screen
Control – UPages up half a screen
Change Commands
cwChanges characters of current word until escape key is pressed
c$Changes text up to the end of the line
C or ccChanges remaining text on the current line until escape key is pressed
~Changes case of the current character
xpTransposes the current and following characters
JJoins current line with the next line
sDeletes current character and enters insertion mode
rxReplaces current character with x
RReplaces the following characters until escape key is pressed
yyPuts current line in a buffer without deleting the line
pPlaces the line stored in buffer after the current position of the cursor
Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.