Cheat sheets

Vim survival guide: exit, save, undo and search

Stuck in Vim? How to get out, plus the handful of keys you need to edit a file and leave.

Handy? Press ⌘ DCtrl + D to bookmark this page for next time.

  1. Leave without saving
    Inside Vim
    :q!

    Press Esc first, so Vim is ready for a command.

  2. Save and leave
    Inside Vim
    :wq

    Press Esc first, so Vim is ready for a command.

  3. Just save
    Inside Vim
    :w
  4. Start typing (insert mode)
    Inside Vim
    i

    Press Esc when you're done typing.

  5. Undo, and redo
    Inside Vim
    u

    Redo is Ctrl + r.

  6. Search for a word
    Inside Vim
    /word

    Press n for the next match, N for the previous one.

  7. Delete the current line
    Inside Vim
    dd
  8. Copy the current line and paste it below
    Inside Vim
    yyp
  9. Jump to the start or end of the file
    Inside Vim
    gg

    G (capital) goes to the end.

  10. Find and replace everywhere
    Inside Vim
    :%s/old/new/g
  1. Leave without saving
    Inside Vim
    :q!

    Press Esc first, so Vim is ready for a command.

  2. Save and leave
    Inside Vim
    :wq

    Press Esc first, so Vim is ready for a command.

  3. Just save
    Inside Vim
    :w
  4. Start typing (insert mode)
    Inside Vim
    i

    Press Esc when you're done typing.

  5. Undo, and redo
    Inside Vim
    u

    Redo is Ctrl + r.

  6. Search for a word
    Inside Vim
    /word

    Press n for the next match, N for the previous one.

  7. Delete the current line
    Inside Vim
    dd
  8. Copy the current line and paste it below
    Inside Vim
    yyp
  9. Jump to the start or end of the file
    Inside Vim
    gg

    G (capital) goes to the end.

  10. Find and replace everywhere
    Inside Vim
    :%s/old/new/g
  1. Leave without saving
    Inside Vim
    :q!

    Press Esc first, so Vim is ready for a command.

  2. Save and leave
    Inside Vim
    :wq

    Press Esc first, so Vim is ready for a command.

  3. Just save
    Inside Vim
    :w
  4. Start typing (insert mode)
    Inside Vim
    i

    Press Esc when you're done typing.

  5. Undo, and redo
    Inside Vim
    u

    Redo is Ctrl + r.

  6. Search for a word
    Inside Vim
    /word

    Press n for the next match, N for the previous one.

  7. Delete the current line
    Inside Vim
    dd
  8. Copy the current line and paste it below
    Inside Vim
    yyp
  9. Jump to the start or end of the file
    Inside Vim
    gg

    G (capital) goes to the end.

  10. Find and replace everywhere
    Inside Vim
    :%s/old/new/g