Mastering Vim: A Cheatsheet Guide for Fast & Efficient Text Editing
Vim is a powerful, keyboard-driven text editor that excels in speed and efficiency. This cheatsheet covers essential commands for navigation, editing, and file management—perfect for beginners or anyone looking to boost their productivity in Vim.

Vim is a powerful, modal text editor that offers unmatched speed and control — once you overcome the steep learning curve. Whether you're a beginner or brushing up, this cheatsheet-style article will help you quickly get up to speed and boost your productivity.
🧠 Understanding Vim Modes
Vim operates in modes — each with a specific purpose:
- Normal mode: for navigation and editing (press
Esc
to enter) - Insert mode: for typing text (
i
,a
,o
, etc.) - Visual mode: for selecting text (
v
,V
,Ctrl+v
) - Command-line mode: for commands like saving and quitting (
:
from Normal mode)
🧭 Movement
Move the cursor:
h
– leftj
– downk
– upl
– right
Word and line navigation:
w
– next wordb
– previous worde
– end of word0
– beginning of line^
– first non-blank character of line$
– end of line
File navigation:
gg
– start of fileG
– end of file:n
– go to line n (e.g.:3
moves to line 3)%
– jump between matching()
{}
[]
Scrolling:
Ctrl-d
– scroll down half-pageCtrl-u
– scroll up half-pageCtrl-f
– scroll forward one pageCtrl-b
– scroll back one page
✍️ Inserting Text
i
– insert before cursorI
– insert at beginning of linea
– append after cursorA
– append at end of lineo
– open new line belowO
– open new line above
🔧 Editing
x
– delete character under cursorX
– delete character before cursorr<char>
– replace characterR
– enter replace modeJ
– join current line with the nextu
– undoCtrl-r
– redo.
– repeat last command
📋 Copy, Paste, and Delete
yy
– yank (copy) current liney<motion>
– yank based on motion (e.g.yw
,y$
)p
– paste after cursorP
– paste before cursordd
– delete current lined<motion>
– delete based on motion (e.g.dw
,d$
)
Working with registers:
"ay
– yank into registera
"ap
– paste from registera
🔍 Search and Replace
Searching:
/pattern
– search forward?pattern
– search backwardn
– repeat search forwardN
– repeat search backward
Replacing:
:s/old/new/
– replace first match on current line:s/old/new/g
– replace all matches on current line:%s/old/new/g
– replace all in file:%s/old/new/gc
– replace all with confirmation
📐 Visual Mode (Selection)
v
– start visual selection (character mode)V
– linewise selectionCtrl+v
– blockwise selectiond
– delete selectiony
– yank selection>
– indent selection<
– un-indent selection~
– toggle case of selection
💾 File and Buffer Commands
File operations:
:e filename
– open file:w
– save:w filename
– save as:q
– quit:q!
– quit without saving:wq
orZZ
– save and quit:x
– save if needed and quit
Buffers (multiple open files):
:ls
– list open buffers:bnext
or:bn
– next buffer:bprev
or:bp
– previous buffer:bd
– delete (close) buffer:b <number>
– switch to buffer
🔁 Macros
q<register>
– start recording macro to register<commands>
– perform your actionsq
– stop recording@<register>
– play macro@@
– repeat last macro
⚙️ Useful Settings
:set number
– show line numbers:set relativenumber
– show relative line numbers:set ignorecase
– ignore case in search:set smartcase
– ignore case unless uppercase used:set hlsearch
– highlight search matches:set incsearch
– incremental search:syntax on
– turn on syntax highlighting:noh
– clear search highlight
📌 Essential Commands Recap
- Save:
:w
- Quit:
:q
- Save and Quit:
:wq
- Quit without saving:
:q!
- Search:
/pattern
- Replace all:
:%s/old/new/g
- Undo:
u
- Redo:
Ctrl-r
- Open file:
:e filename
✅ Tips
- Start slow. Learn
hjkl
,i
,:wq
, and/search
first. - Practice motions with commands (
d
,y
,c
) to operate efficiently. - Use
.
to repeat last change — it’s a huge time-saver. - Explore
:help
for anything (:help :wq
,:help visual
).