# Vim

# Shortcuts

Command Mode:

  • :q - quit
  • :w - write the current state to the file
  • :wq - save and quit
  • :q! - quit without saving
  • :set number - turns on line numbering
  • i - Press i go enter Insert mode
  • :%s/find/replace/ - Find and replace first occurrence. Replace find and replace accordingly.
  • :%s/find/replace/g - Find and replace greed mode, all occurrences.
  • :%s/find/replace/gc - Find and replace greed mode with confirmation to all occurrences.

Insert mode:

  • esc - get back to command mode
  • dd - delete a line
  • 2dd - delete 2 line (if you put a number x before a command It will try to execute the command x times)
  • u - undo last action
  • ctrl r - redo
  • / - search (Type forward slash, and the subject you want to search) within the search press n to forward the search and N to back. When you find type i to edit.