My Vim Cheat Sheet

Here is the list of frequently used Vim commands. If you are an advanced Vim user, you might not find anything new. This list comes in handy for me as not all are committed to my muscle memory yet!

  • Ctrl + d - Scroll half page down
  • Ctrl + u - Scroll half page up
  • M - Move to center of the screen
  • 3gg - Go to line number(3 in this case)
  • 3G - Go to line number (3 in this case)
  • g; - Go to last edit location
  • % - Find closing bracket/ parenthesis/ quote
  • :vs - Vertical-split the file
  • + - Go to the first non-space character on the next line
  • - - Go to the first non-space character on the previous line
  • /xx - Search word ‘xx’
  • f* - Find specific character(* = character to find)
  • ; - Repeat the previous search in forward direction
  • , - Repeat the previous search in backward direction
  • * - Search the word under cursor - forward
  • # - Search the word under cursor - reverse
  • :noh - No highlight (hide the words highlighted as search result)

Edit

  • I - Move to the first character of the line and get in edit mode
  • A - Move to the last character of the line and get in edit mode
  • o - Open new line below the current line
  • O - Open new line above the current line
  • U - Change selection to upper case
  • u - Change selection to lower case
  • ~ - Flip the case of selection
  • ci” - Change text inside double quotes
  • cit - Change inside tag
  • :j3 - Join given number of lines(3 in this case)

Select & Copy/Paste

  • yiw - Yank inside a word
  • viwp - Visually select word & paste
  • ggyG - Yank all lines
  • Yp - Yank and paste(alternative to yyp)
  • vat - Visually select around(including) tag
  • vit - Visually select inside tag
  • shift + v - Select current line(use j & k to expand/ contract selection)

Delete

  • D - Delete rest of the line
  • d$ - Delete rest of the line
  • C - Delete & Edit rest of the line
  • 0c - Delete whole line & Insert
  • rx - Replace current character with given character (x in this case)
  • x - Delete character under the cursor
  • dap - Delete paragraph
  • dat - Delete around(including) tag
  • dit - Delete inside tag

Misc.

  • q - Stop recording macro (if you tend to hit record by mistake like me and don’t know how to get out of it!)
  • :qa - Quit All(close all tabs)
  • :wq - Write & Quit(save and close all)