Skip to content

Instantly share code, notes, and snippets.

@sany2k8
Last active March 25, 2017 08:16
Show Gist options
  • Save sany2k8/17fc40c69c9680f3b9f44e01d1e70dab to your computer and use it in GitHub Desktop.
Save sany2k8/17fc40c69c9680f3b9f44e01d1e70dab to your computer and use it in GitHub Desktop.
Vim important cheat sheet
General
w - jump by start of words (punctuation considered words)
W - jump by words (spaces separate words)
e - jump to end of words (punctuation considered words)
E - jump to end of words (no punctuation)
b - jump backward by words (punctuation considered words)
B - jump backward by words (no punctuation)
0 - (zero) start of line
^ - first non-blank character of line (same as 0w)
$ - end of line
u - undo
Ctrl+r - redo
. - = Repeat last command
:t.+ Enter = Duplicate Line
Exiting
:w - write (save) the file, but don't exit
:wq OR :x OR ZZ - write (save) and quit
:q - quit (fails if anything has changed)
:q! - quit and throw away changes
Search/Replace
:12 - go to line number 12
:set number - set line number in editor
/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 (gn is better though)
:%s/old/new/gc - replace all old with new throughout file with confirmations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment