Skip to main content

Command Palette

Search for a command to run...

Vim Cheat Sheet

Updated
•3 min read•View as Markdown
Vim Cheat Sheet
R
Markdown + Vim fan. Love sharing knowledge with the community Dev-san, gambare! ᕙ( •̀ ᗜ •́ )👍

I have this list of vim commands I use frequently that I want to share with you to help you get basic things done in your editor.

Copy and paste

from normal mode (press Esc to access it) you can copy to system clipboard in vim with

Auto

y // yank (copy)
p // paste

there is also this longer command to use multiple registers to copy and paste

Auto

"*y // copy to selection clipboard
"+y // copy to system clipboard
"+d // cut to system clipboard
"ay // copy to register a

"ap // paste from a register

Search in document (case insensitive)

/\cSTRING_TO_SEARCH

Find and Replace

Replace all
:%s/old_word/new_word/g
Replace one by one
:%s/old_word/new_word/gc 

Cursor between words

w // go to beggining of next word
e // go to end of current/next word
b // go to beggining of current/prev word
ge // go to end of previous word
  • From these I mostly use e and b

Scroll inside the page

Ctrl‑d / Ctrl‑u → half‑page scroll down/up.
Ctrl‑f / Ctrl‑b → full‑page scroll down/up.

Scrollbar with Cursor to top/middle/bottom of screen

zt || z<enter> // top
zz || z/ // middle
zb || z- // bottom

Go to start/end of buffer

gg // start
G // end

Visual mode

this mode lets you select text showing visually what you have selected. This is useful to copy text. Enter/exit this mode with v once in visual mode you can use the commands shown previously to navigate along the text. The nice thing about this mode is that you can use o to move the cursor to the beggining or end of your selection. This allows you to select more text to the left or the right. I always wondered why notepad or nano doesnt have that feature which I finally found in Vim!

v // enter/exit visual mode
o // go to beggining/end of selected text in visual mode
vat // select text around a tag
vit // select text inside a tag

How to get used to all these commands?

As a first challenge Use Vimium or Vimium-c on your browser. It lets you use vim command in your browser to surf the web minimizing the need for a mouse, improving ergonomics and helping you be faster.

After getting used you can start using NeoVim extension in VS Code, Windsurf, etc. this will let you apply vim command in your codding projects.

Finally when you are ready to use the commands with dexterity I recommend you use a light weight editor full of Vim commands to accelerate your developement even more. Try NV Chad

Keep progressing one step at a time. 🪜✨

Mess as much as you want once you know you can undo with u. 🧪↩️⌨️

Happy Coding! 🚀💻