Skip to content

Instantly share code, notes, and snippets.

@gostrafx
Last active May 19, 2019 22:17
Show Gist options
  • Save gostrafx/ec15327e4ebaaa110d94542882ffe0a3 to your computer and use it in GitHub Desktop.
Save gostrafx/ec15327e4ebaaa110d94542882ffe0a3 to your computer and use it in GitHub Desktop.
Vim cheat sheet

A highly opinionated vim cheat sheet.

Copy / Cut / Paste (normal mode)

  • selecting:
    • v: start selecting characters
    • V: selects the whole line
  • action:
    • d: to cut
    • y: to copy
    • p: to paste after the cursor
    • gp: to paste after the cursor and then move the cursor at the end of the pasted text
    • P: to paste before the cursor
    • gP: to paste before the cursor and then move the cursor at the end of the pasted text

History

  • u: undo last change
  • Ctrl-R: redo last undone change

Motions

Word / WORD

  • w: move to the start of the next word
  • e: move to the end of the current or next word
  • b: move to the start of the current or previous word

Note: upper case next word motions (e.g. W) will consider "word" as being 1 WORD, instead of 3 words.

Inline occurence

  • f: move to the next character occurence in the current line
  • t: move one character before the next character occurence in the current line
  • ;: repeats the previous inline motion

Note: upper case inline motions (e.g. F) will move to previous occurence.

Splits

  • Ctrl-W v: creates a new vertical split
  • Ctrl-W s: creates a new horizontal split
  • Ctrl-W q: closes the current split
  • Ctrl-W h: switches the right split
  • Ctrl-W l: switches the left split

Misc

  • Ctrl-N: autocomplete word
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment