Skip to content

Instantly share code, notes, and snippets.

@froggr
Forked from joejag/cheats.txt
Last active December 26, 2015 01:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save froggr/7075608 to your computer and use it in GitHub Desktop.
Save froggr/7075608 to your computer and use it in GitHub Desktop.

###Vim Cheat Sheet

MOVEMENT

  • Basic movement: h j k l (left, down,up, right)
  • Word movement: w b (next, back) W B (ignore punct)
  • Number powered movement: 3w
  • Start of line: 0, end $
  • Start doc: gg, end: G, line: 6G
  • Next page: CTRL+f, Back page: CTRL+b, 1/2 versions: CTRL+d, CTRL+u
  • Last postion in another file jumping: CTRL+0, CTRL+TAB (back, forward)

SEARCH

  • Search /text, n and N to move
  • Find a character: f[char] F[char] (next, previous), ; and , to repeat
  • Matching parens: %
  • Find word under cursor * and #

INSERT/DELETE

  • Insert/Append start/end: I A
  • Delete to end of line: D
  • Clear current line; to insert mode: S
  • Insert new line: o and O (below or above)
  • Delete x, backspace X
  • Replace under cursor: r
  • Delete word with: d (like d2w for deleting 2 words)

VISUAL

  • Visual mode: v (character orientated)
  • Visual mode: V (line orientated)
  • Visual mode: CTRL+V (Block visual select rectangles of text)

COPY/PASTE

  • Copy current line: yy
  • Paste copied text after cursor: p

COMMENTING OUT CODE

  • Comment: CTRL+V (select lines) I#
  • Uncomment: CTRL+V (select lines) X

MISC

  • Repeat command with: .
  • Undo: u, redo: CTRL+R
  • Autocomplete word: CTRL+P
  • open file: :e [file]

TABS

  • New tab: :tabnew
  • Switch tabs (forward): gt
  • Switch tabs (backwards): gT
  • Switch tabs (to tab number): {i}gt
  • Open files: tab -p *.log

WINDOWS

  • Ctrl-W s for horizontal splitting
  • Ctrl-W v for vertical splitting
  • Ctrl-w q to close one
  • Change window: CTRL+W [direction]

PASTING INTO VIM

  • :set paste -> to remove tabbing when using ctrl-v
  • :set nopaste -> to go back to normal tabbing

REBINDING KEYS FOR MAC...

  • to find a key, in terminal type sed -n l
  • ^[ means so the UP key on my current mac would be [A

LINKS

VIMRC FOR INSPIRATION

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment