VIM Editor Cheatsheet

Vim (Vi IMproved) is a powerful, highly configurable text editor used in Linux for programming, scripting, and general text editing. It provides efficient navigation, powerful search, and extensive customization. Vim operates in different modes:

  • Normal Mode: Default mode for navigation and commands.

  • Insert Mode: Used for inserting/editing text.

  • Visual Mode: Used for selecting text.

  • Command Mode: Used for executing commands (: commands).

Basic Vim Commands

CommandDescription
vim filenameOpen a file in Vim.
:qQuit Vim.
:q!Quit without saving changes.
:wSave (write) changes.
:wq or ZZSave and quit.
:xSave and quit (only if changes were made).

Switching Modes

CommandDescription
iInsert mode at cursor.
IInsert at beginning of the line.
aAppend after cursor.
AAppend at the end of the line.
oOpen a new line below.
OOpen a new line above.
EscSwitch to Normal mode.

Navigation Commands

CommandDescription
hMove left.
lMove right.
jMove down.
kMove up.
0Move to the beginning of the line.
^Move to the first non-blank character of the line.
$Move to the end of the line.
ggGo to the beginning of the file.
GGo to the end of the file.
nGGo to line number n.
Ctrl + dScroll down half a screen.
Ctrl + uScroll up half a screen.

Copy, Cut, and Paste (Yank & Delete)

CommandDescription
yyCopy (yank) current line.
nyyCopy n lines.
pPaste after cursor.
PPaste before cursor.
ddCut (delete) current line.
nddCut (delete) n lines.
d$Delete from cursor to end of line.
d0Delete from cursor to beginning of line.

Exiting & Saving

CommandDescription
:qQuit (if no changes).
:q!Quit without saving.
:wSave changes.
:wq / ZZSave and quit.
0
Subscribe to my newsletter

Read articles from Nitheesh Prakashan Parayil directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Nitheesh Prakashan Parayil
Nitheesh Prakashan Parayil