Keyhab
:wq
Vim

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.

ModePurposeHow to Enter
NormalNavigate and manipulate textPress Esc from any mode
InsertType text like a regular editorPress i, a, o, etc.
VisualSelect textPress v, V, or Ctrl + v
CommandExecute commandsPress : from Normal mode
ReplaceOverwrite textPress 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:

KeyAction
hMove left
jMove down
kMove up
lMove right
wJump forward one word
bJump backward one word
eJump to end of word
0Go to beginning of line
$Go to end of line
^Go to first non-blank character
ggGo to first line
GGo to last line
{number}GGo to line number
Ctrl + dScroll half-page down
Ctrl + uScroll half-page up
Ctrl + fScroll full page down
Ctrl + bScroll full page up
%Jump to matching bracket

---

Entering Insert Mode

KeyAction
iInsert before cursor
IInsert at beginning of line
aAppend after cursor
AAppend at end of line
oOpen new line below
OOpen new line above
sSubstitute character and enter insert
SSubstitute entire line

---

Editing Commands

All of these work in Normal mode:

CommandAction
xDelete character under cursor
XDelete character before cursor
ddDelete (cut) entire line
DDelete from cursor to end of line
dwDelete word
d$Delete to end of line
d0Delete to beginning of line
yyYank (copy) entire line
ywYank word
y$Yank to end of line
pPaste after cursor
PPaste before cursor
uUndo
Ctrl + rRedo
.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 — delete
  • c — change (delete and enter insert mode)
  • y — yank (copy)
  • > — indent
  • < — outdent

Examples

CommandMeaning
d3wDelete 3 words
c2jChange current line and next 2 lines
y5lYank 5 characters to the right
di"Delete inside double quotes
ci(Change inside parentheses
da{Delete around curly braces (including braces)
yiwYank inner word
diwDelete 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

CommandAction
/patternSearch forward
?patternSearch backward
nNext match
NPrevious match
*Search for word under cursor
#Search backward for word under cursor
:%s/old/new/gReplace all in file
:%s/old/new/gcReplace all with confirmation
:s/old/new/gReplace all in current line

---

Visual Mode

KeyAction
vCharacter-wise visual selection
VLine-wise visual selection
Ctrl + vBlock (column) visual selection
gvReselect last visual selection

Once selected, you can apply any operator (d, y, c, >, <, etc.) to the selection.

---

Working with Files

CommandAction
:wSave
:qQuit
:wq or :xSave and quit
:q!Quit without saving
:e filenameOpen file
:bn / :bpNext / previous buffer
:lsList open buffers
:spHorizontal split
:vspVertical split
Ctrl + w, h/j/k/lNavigate between splits

---

Marks and Jumps

CommandAction
maSet mark a at current position
'aJump to line of mark a
\a`Jump to exact position of mark a
Ctrl + oJump to previous location
Ctrl + iJump to next location

---

Macros

Macros let you record and replay a sequence of commands.

  1. Press qa to start recording into register a.
  2. Perform your edits.
  3. Press q to stop recording.
  4. Press @a to replay the macro.
  5. Press @@ to repeat the last macro.
  6. Press 10@a to 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

  1. Start with the basics. Learn h j k l, insert mode, saving, and quitting. That is enough to be functional.
  2. Learn one new command per day. Do not try to memorize everything at once.
  3. Use Vimtutor. Run vimtutor in your terminal for a built-in interactive tutorial.
  4. Practice with spaced repetition. Tools like Keyhab can help you drill Vim shortcuts until they become muscle memory.
  5. 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.

:wq

Learn Vim shortcuts with quick quizzes

Keyhab quizzes you on 1,050 shortcuts for 15 tools, from Basics to Advanced. Five minutes a day on iPhone or iPad — VSCode (Mac) and Vim Basics are free.

Download free on the App Store

Related