DEV Community

Alexand
Alexand

Posted on

Essential Vim Commands: Your Quick Guide to Mastering Vim

📋 Table of Contents
🚦 Vim Modes

💾 Basic File Operations

🧭 Navigation

✍️ Editing Text

🔍 Search & Replace

🪟 Buffers, Windows & Tabs

💡 Pro Tips

✅ Quick Practice

🚦 Vim Modes
Vim works in different modes:

Mode Description Enter by
Normal Navigate and run commands Esc
Insert Type and edit text i, I, a, etc.
Visual Select text v, V
💾 Basic File Operations
Command Description
:w Save file
:q Quit Vim
:wq Save and quit
:q! Quit without saving
:x Save if needed, then quit
:e Open another file
:r Insert contents of another file
🧭 Navigation
Key Action
h, j, k, l Left, Down, Up, Right
w, W Next word
b, B Previous word
0, ^, $ Line start, first char, end
gg, G Start / end of file
:n Go to line number n
Ctrl-d, Ctrl-u Half-page down / up
✍️ Editing Text
Command Description
i, I Insert at cursor / line start
a, A Append after cursor / line end
o, O New line below / above
r, R Replace char / enter Replace mode
u, Ctrl-r Undo / redo
x, dd Delete char / delete line
yy, p, P Copy line / paste after / before
🔍 Search & Replace
Command Description
/pattern Search forward
?pattern Search backward
n, N Next / previous match
:%s/old/new/g Replace all
:%s/old/new/gc Replace with confirmation
:s/old/new/ Replace in current line
🪟 Buffers, Windows & Tabs
Command Description
:ls List open buffers
:bN Switch to buffer N
:split / :vsplit Split window horizontally / vertically
Ctrl-w w Cycle through windows
:tabnew Open a new tab
gt, gT Next / previous tab
💡 Pro Tips
Always press Esc to return to Normal mode.

Use :help to explore Vim documentation (e.g., :help gg).

Practice one command a day to build muscle memory.

✅ Quick Practice
Try this short routine:

Open a file: vim test.txt

Enter Insert mode: i, then type some text

Press Esc to return to Normal mode

Save and quit: :wq

You’ve just taken your first step toward mastering Vim! 🚀

Top comments (0)