Vim Keystrokes

This is a list of keystroks that for the life of me I cannot remember and need to check each time.

Switching Case of Characters

lower case to UPPER CASE: gU or g~ + movement

UPPER CASE to lower case: gu or g~ + movement

Comment/Uncomment Multiple Lines

The keystroke to select multiple line is common for all command.

  • Place the cursor to the first line you want to comment and press Ctrl + V to put the editor in VISUAL BLOCK mode.
  • Using the arrow key (or h j k l) select every line to comment/uncomment.
  • Press Shift + I to put the editor in INSERT mode and then press # to comment or x to uncomment (delete).
  • Last, press Esc to insert a # character/delete every selected haracter on all other selected lines.

Refactoring Variables

  • Place cursor on variable to rename
  • Type gd (or gD for global variable)
  • c to change
  • gn to search for last used search pattern
  • Type variable’s new name
  • esc to exit
  • . to repeat and apply to next occurences
Links to this page