Vim Cheat Sheet

Vim
About the Newsletter

Join 100+ subscribers who get 0x1 actionable security bit every week.

Mastering Vim has been both challenging and rewarding. In this evolving cheat sheet, I share frequently used shortcuts seamlessly integrated into my VSCode and Obsidian workflow. Here are key commands that have proven invaluable in my ongoing Vim journey.

Cursor Movement
  • h – move cursor left
  • j – move cursor down
  • k – move cursor up
  • l – move cursor right
  • f/F<char> – move to next( or previous) occurrence of character
  • 0 – jump to the start of the line
  • $ – jump to the end of the line
  • gg – go to the first line of the document
  • G – go to the last line of the document
  • w – jump forwards to the start of a word
  • W – jump forwards to the start of a word (words can contain punctuation)
  • Ctrl + b – move screen up one page (cursor to last line)
  • Ctrl + f – move screen down one page (cursor to first line)
Editing
  • . – repeat last command
  • u – undo
  • Ctrl + r – redo
  • r – replace a single character.
  • R – replace more than one character, until ESC is pressed.
Cut & Paste
  • yy – yank (copy) a line
  • 2yy -yank (copy) 2 lines
  • yw – copy word
  • p – put (paste) the clipboard after cursor

 

  • d$ or D – delete (cut) to the end of the line
  • dd – delete a line
  • 2dd – delete 2 lines
  • dw – delete word
  • d2w – delete 2 words
  • di' – delete inside ‘
  • x – delete (cut) character
  • :g/{pattern}/d – delete all lines containing pattern
  • :g!/{pattern}/d – delete all lines not containing pattern
Search & replace
  • /pattern – search for pattern
  • ?pattern – search backward for pattern
  • \vpattern – ‘very magic’ pattern: non-alphanumeric characters are interpreted as special regex symbols (no escaping needed)
  • n – repeat search in same direction
  • N – repeat search in opposite direction
  • :%s/old/new/g – replace all old with new throughout file
  • :%s/old/new/gc – replace all old with new throughout file with confirmations
  • :noh[lsearch] – remove highlighting of search matches

Tips

  • Use this to see help for cmd :help w
  • Prefix a cursor movement command with a number to repeat it. For example, 4j moves down 4 lines.
  • W– Much faster than w

Resources

All credit for these commands goes to the creators behind the below cheatsheet, and I’m grateful for their contribution to the Vim community.

Thanks for reading. Feel free to connect with me on or LinkedIn for any suggestions or comments.

For more updates and exclusive content, subscribe to our newsletter. Happy Reversing! 😊

Join 100+ subscribers who get 0x1 actionable security bit every week.




Related Posts

No results found.
keyboard_arrow_up