Skip to content

Vi Linux editor cheatsheet

  • by
  • 3 min read

Vi is the default text editor with the Linux system, and vi is the visual editor. Vi is a common text editor in almost every Linux system. This article would be a cheat sheet for you to refer to whenever you want to use the vi editor.

Also read: How to save and exit in Vim?

Basics of the vi editor

The vi editor has two modes of operation:

  • Command Mode: The command mode is the mode where you specify what action you want to implement on your file.
  • Insert Mode: The insert mode is where you insert the data into your file.

You can open or create a new file in the vi editor by simply using the command given below.

vi <file name>

You can press ESC followed by the colon “:” to go into the command mode.

Vi Linux editor cheatsheet

You can press ‘i’ to go into the insert mode.

Vi Linux editor cheatsheet

Vi vs Vim

An important thing to note is the difference between Vi and Vim. Vi is the base editor, while Vim stands for “Vi Improved” and is an enhanced version of the editor with additional features.

On most Linux distributions, Vi and Vim are interchangeable. If you try and launch Vi, you’ll likely end up in Vim. However, some distributions still require users to manually install Vim if they want to use the enhanced editor.

Also read: How to undo/redo in Vim?

Vi commands

Let’s see the commands that are used in the vi editor.

:wq or ZZSave and quit editor
:q!Quit without saving
yyYank (copy) the selected line
pPaste a line of yanked (copied) text
oOpens a new line under the current line
0 (zero)Opens a new line above the current line
AAppend text at the end of the current line
aAppend text after the cursor’s current position
IInsert text at the beginning of the current line
bGo to the beginning of the current word relative to the cursor’s position
eGo to the end of the current word relative to the cursor’s position
xDelete a single character preceding the cursor
ddDelete the entire active line
XddDelete multiple lines after the cursor. X denotes the number of lines
XyyYank (copy) multiple lines following the cursor. X denotes the number of lines
GJump to the last line in a file
XGJump to a specific line. X denotes the line number.
ggJump to the first line in a file
:numDisplay the active line’s line number
hMove one character to the left of the cursor
jMove one character under the cursor
kMove one character above the cursor
lMove one character to the right of the cursor

(With inputs from Chetali Shah)

Also read: How to delete lines in Vim?

Yadullah Abidi

Yadullah Abidi

Yadullah is a Computer Science graduate who writes/edits/shoots/codes all things cybersecurity, gaming, and tech hardware. When he's not, he streams himself racing virtual cars. He's been writing and reporting on tech and cybersecurity with websites like Candid.Technology and MakeUseOf since 2018. You can contact him here: