Table of Contents > Linux > VI Reference

VI Reference

VI is a minimalistic text editor that is found on most varities of Unix, including Linux. It typically does not have a graphical user-interface, which means that most of its functionality is accessed through obscure keyboard commands. I've always had a hard time remembering all of the commands, so I've made a short reference to the commands that I've found useful. You can obtain a complete list of these commands by typing ':help' while running VI. Note that some of these commands may be specific to the version of VI that I am running (VIM 5.8.7), so you might not get all of them to work in your version.

The Basics

These are the commands that you will use most frequently.

i
Puts you into Insert mode, which allows you to add new text.
ESC key
Takes you out of any mode and into Normal mode.
x
Deletes the character under the cursor.
gg
Moves the cursor to the start of the file.
G
Moves the cursor to the end of the file.
dd
Deletes the current line.
yy
Copies the current line to the clipboard.
D
Deletes from the character under the cursor to the end of the line.
p
Pastes the previously deleted/yanked text after the current character.
P
Pastes the previously deleted/yanked text before the current character.
u
Undo the last command/edit.
.
Redo the last command/edit.
v
Puts you into Visual mode, which allows you to select a range of characters.
V
Puts you into Visual mode, but selects entire lines.
J
Joins the next line onto the end of the current line.
>>
Indent a line by one tab.
<<
Unindent a line by one tab.

Repetition

Allows you to repeat a single command multiple times.

#dd
Deletes # lines.
#yy
Copies # lines to the clipboard.
#G
Moes the cursor to the #'th line of the file.
Page View Tracker