VIM Editor Cheatsheet

3 min read

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
Command | Description |
vim filename | Open a file in Vim. |
:q | Quit Vim. |
:q! | Quit without saving changes. |
:w | Save (write) changes. |
:wq or ZZ | Save and quit. |
:x | Save and quit (only if changes were made). |
Switching Modes
Command | Description |
i | Insert mode at cursor. |
I | Insert at beginning of the line. |
a | Append after cursor. |
A | Append at the end of the line. |
o | Open a new line below. |
O | Open a new line above. |
Esc | Switch to Normal mode. |
Navigation Commands
Command | Description |
h | Move left. |
l | Move right. |
j | Move down. |
k | Move up. |
0 | Move to the beginning of the line. |
^ | Move to the first non-blank character of the line. |
$ | Move to the end of the line. |
gg | Go to the beginning of the file. |
G | Go to the end of the file. |
nG | Go to line number n . |
Ctrl + d | Scroll down half a screen. |
Ctrl + u | Scroll up half a screen. |
Copy, Cut, and Paste (Yank & Delete)
Command | Description |
yy | Copy (yank) current line. |
nyy | Copy n lines. |
p | Paste after cursor. |
P | Paste before cursor. |
dd | Cut (delete) current line. |
ndd | Cut (delete) n lines. |
d$ | Delete from cursor to end of line. |
d0 | Delete from cursor to beginning of line. |
Exiting & Saving
Command | Description |
:q | Quit (if no changes). |
:q! | Quit without saving. |
:w | Save changes. |
:wq / ZZ | Save 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
