Skip to content

Instantly share code, notes, and snippets.

@melklein
Last active July 6, 2016 10:39
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 melklein/591c56c52fa97fb7810a to your computer and use it in GitHub Desktop.
Save melklein/591c56c52fa97fb7810a to your computer and use it in GitHub Desktop.
useful vim commands
  • increase number under cursor: ctrl+a
  • decrease number under cursor: ctrl+x
  • replace one word with another: select first word, e.g. vi"; select second word vi" and paste p
  • search from within vim, don't jump to first match: vimgrep /render_show/gj **/*.rb

Resize splits

  • resize horizontal split: ctrl+w - / ctrl+w +
  • resize horizontal split to maximum: ctrl+w _
  • make horizontal and vertical splits equally big: ctrl+w =
  • resize vertical split: ctrl+w < / ctrl+w >

Buffers

  • list buffers: ls
  • go to previous buffer: e#
  • go to buffer with number: e#1

Tabs

  • new tab: :tabnew
  • next tab: :tabn
  • previous tab: :tabp
  • rotate throught tabs: gt in normal mode
  • go to tab with number: :tabm <tab_number>
  • open files in tabs when starting vim: vim -p file1 file2 file3
  • search and replace in all tabs: :tabdo %s/foo/bar/gc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment