Vim Cheat Sheet — Essential Commands for Beginners
Learn Vim from scratch with this beginner-friendly cheat sheet. Covers modes, navigation, editing, search, and advanced commands.
Why Learn Vim in 2026?
Vim has been around since 1991, yet it remains one of the most efficient text editors ever created. It is pre-installed on virtually every Unix system, it is lightning-fast even on remote servers via SSH, and its modal editing model — once learned — lets you edit text faster than any GUI editor.
Whether you want to use Vim as your primary editor or just survive when you land in a terminal, this cheat sheet will give you everything you need.
---
Understanding Vim Modes
Vim operates in distinct modes, and understanding them is the key to using Vim effectively.
| Mode | Purpose | How to Enter |
|---|---|---|
| Normal | Navigate and manipulate text | Press Esc from any mode |
| Insert | Type text like a regular editor | Press i, a, o, etc. |
| Visual | Select text | Press v, V, or Ctrl + v |
| Command | Execute commands | Press : from Normal mode |
| Replace | Overwrite text | Press R from Normal mode |
Golden rule: When in doubt, press Esc to return to Normal mode.
---
Basic Navigation
In Normal mode, you move the cursor without arrow keys:
| Key | Action |
|---|---|
h | Move left |
j | Move down |
k | Move up |
l | Move right |
w | Jump forward one word |
b | Jump backward one word |
e | Jump to end of word |
0 | Go to beginning of line |
$ | Go to end of line |
^ | Go to first non-blank character |
gg | Go to first line |
G | Go to last line |
{number}G | Go to line number |
Ctrl + d | Scroll half-page down |
Ctrl + u | Scroll half-page up |
Ctrl + f | Scroll full page down |
Ctrl + b | Scroll full page up |
% | Jump to matching bracket |
---
Entering Insert Mode
| Key | Action |
|---|---|
i | Insert before cursor |
I | Insert at beginning of line |
a | Append after cursor |
A | Append at end of line |
o | Open new line below |
O | Open new line above |
s | Substitute character and enter insert |
S | Substitute entire line |
---
Editing Commands
All of these work in Normal mode:
| Command | Action |
|---|---|
x | Delete character under cursor |
X | Delete character before cursor |
dd | Delete (cut) entire line |
D | Delete from cursor to end of line |
dw | Delete word |
d$ | Delete to end of line |
d0 | Delete to beginning of line |
yy | Yank (copy) entire line |
yw | Yank word |
y$ | Yank to end of line |
p | Paste after cursor |
P | Paste before cursor |
u | Undo |
Ctrl + r | Redo |
. | Repeat last command |
~ | Toggle case of character |
>> | Indent line |
<< | Outdent line |
---
The Power of Vim: Combining Operators and Motions
Vim commands follow a grammar: operator + motion (or operator + text object).
Common operators
d— deletec— change (delete and enter insert mode)y— yank (copy)>— indent<— outdent
Examples
| Command | Meaning |
|---|---|
d3w | Delete 3 words |
c2j | Change current line and next 2 lines |
y5l | Yank 5 characters to the right |
di" | Delete inside double quotes |
ci( | Change inside parentheses |
da{ | Delete around curly braces (including braces) |
yiw | Yank inner word |
diw | Delete inner word |
ci' | Change inside single quotes |
dt; | Delete until semicolon |
This composable grammar is what makes Vim so powerful. Once you internalize the operators and motions, you can combine them freely.
---
Search and Replace
| Command | Action |
|---|---|
/pattern | Search forward |
?pattern | Search backward |
n | Next match |
N | Previous match |
* | Search for word under cursor |
# | Search backward for word under cursor |
:%s/old/new/g | Replace all in file |
:%s/old/new/gc | Replace all with confirmation |
:s/old/new/g | Replace all in current line |
---
Visual Mode
| Key | Action |
|---|---|
v | Character-wise visual selection |
V | Line-wise visual selection |
Ctrl + v | Block (column) visual selection |
gv | Reselect last visual selection |
Once selected, you can apply any operator (d, y, c, >, <, etc.) to the selection.
---
Working with Files
| Command | Action |
|---|---|
:w | Save |
:q | Quit |
:wq or :x | Save and quit |
:q! | Quit without saving |
:e filename | Open file |
:bn / :bp | Next / previous buffer |
:ls | List open buffers |
:sp | Horizontal split |
:vsp | Vertical split |
Ctrl + w, h/j/k/l | Navigate between splits |
---
Marks and Jumps
| Command | Action |
|---|---|
ma | Set mark a at current position |
'a | Jump to line of mark a |
\a` | Jump to exact position of mark a |
Ctrl + o | Jump to previous location |
Ctrl + i | Jump to next location |
---
Macros
Macros let you record and replay a sequence of commands.
- Press
qato start recording into registera. - Perform your edits.
- Press
qto stop recording. - Press
@ato replay the macro. - Press
@@to repeat the last macro. - Press
10@ato replay 10 times.
---
Essential .vimrc Settings for Beginners
`vim
set number " Show line numbers
set relativenumber " Relative line numbers
set tabstop=4 " Tab width
set shiftwidth=4 " Indent width
set expandtab " Use spaces instead of tabs
set incsearch " Incremental search
set hlsearch " Highlight search results
set ignorecase " Case-insensitive search
set smartcase " Case-sensitive if uppercase used
syntax on " Syntax highlighting
`
---
Tips for Learning Vim Efficiently
- Start with the basics. Learn
h j k l, insert mode, saving, and quitting. That is enough to be functional. - Learn one new command per day. Do not try to memorize everything at once.
- Use Vimtutor. Run
vimtutorin your terminal for a built-in interactive tutorial. - Practice with spaced repetition. Tools like Keyhab can help you drill Vim shortcuts until they become muscle memory.
- Disable arrow keys to force yourself to use
h j k l.
---
Conclusion
Vim has a steep learning curve, but the payoff is enormous. The modal editing paradigm and composable command language let you perform complex edits with just a few keystrokes. Start with the basics in this cheat sheet, practice consistently, and you will be editing at the speed of thought.