My very short vi cheat sheet



Insert Mode - Inserting/Appending text

  • a - append after the cursor
  • Esc - exit insert mode

Cut and Paste

  • Delete
    • (Acutally, I can use delete key and backspace in Insert Mode)
  • Copy
    • yy - yank (copy) a line
    • yw - yank word
    • y$ - yank to end of line
  • Paste
    • p - put (paste) the clipboard after cursor
    • P - put (paste) before cursor
  • Cut
    • dd - delete (cut) a line
    • dw - delete (cut) the current word
    • x - delete (cut) current character

Exiting

  • :w - write (save) the file, but don't exit
  • :wq - write (save) and quit
  • :q - quit (fails if anything has changed)
  • :q! - quit and throw away changes

Search/Replace

  • /pattern - search for pattern
  • ?pattern - search backward for pattern
  • 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

Comments

Popular Posts