Vim Tips and Tricks

  • :e! Forced reload current of file
  • zz Scroll current line to center
  • zt Scroll current line to top
  • zb Scroll current line to bottom
  • 10zl Scroll rightward 10 chars
  • ZZ Write, if changed, and quit
  • % Jump to corresponding brace
  • H Jump to top visible line
  • M Jump to middle visible line
  • L Jump to bottom visible line
  • qa Record a macro named 'a', q to stop recording
  • @a Execute macro named 'a'
  • @@ Execute last macro used
  • ma Set mark named 'a'
  • 'a Jump to beginning of the line for mark 'a'
  • `a Jump to mark 'a'
  • :marks List all marks
  • [ or ] and ' or ` Jump backward/forward between the two mark types
  • `. Jump to last change
  • '' Jump to the line of the cursor's previous location
  • `` Jump to the cursor's previous location
  • ` [ or ] Jump to the beginning/end of the recently yanked or pasted text
  • f Like t but inclusive
  • ; Repeat last f or t movement
  • :%s/foo/bar/gc Replace foo for bar anywhere in the file, requesting confirmation
  • CtrlP <c-d> Filename search only
  • CtrlP <c-v> Open file in vertical split
  • CtrlP <c-x> Open file in horizontal split
  • CtrlP <c-t> Open file in new tab
  • :set paste Turn on paste mode
  • <c-w> 10 > or < Resize pane by 10 in selected direction
  • :tabe Open new tab
  • :tabc Close tab
  • :tabm 2 Move tab to position 2
  • gt or gT Go forward or backward through tabs
  • :cp or :cn Move backward or forward through Quickfix list results
  • :cw Open Quickfix list in a split
  • autocomplete <c-g>g Skip to end of autocompleted text
  • * Search current word forward
  • # Search current word backward

Convert DOS to Unix newlines

:set ff=unix