Skip to content

Instantly share code, notes, and snippets.

@booyaa
Created March 30, 2013 13:42
Show Gist options
  • Select an option

  • Save booyaa/5276722 to your computer and use it in GitHub Desktop.

Select an option

Save booyaa/5276722 to your computer and use it in GitHub Desktop.
vim magick

####use mmalecki's dotfiles config

git submodule source: http://vimcasts.org/episodes/synchronizing-plugins-with-git-submodules-and-pathogen/

  • mkdir ~/github
  • cd ~/github
  • git clone git://github.com/mmalecki/dotfiles.git
  • cd dotfiles
  • git submodule init
  • git submodule update
  • ln -s ~/github/dotfiles/vim/vimrc ~/.vimrc
  • ln -s ~/github/dotfiles/vim ~/.vim

####to upgrade a specific a module

  • cd ~/.vim/bundle/tabular
  • git pull origin master

####to upgrade all packages

  • cd ~/github/dotfiles
  • git submodule foreach git pull origin master

####selection

  • ctrl-v (start visual selection by char/columns)
  • shift-V to switch to line mode

####to block comment (assumes you have tcomment)

  • ctrl-shift-_

####formatting

source: http://www.cs.swarthmore.edu/help/vim/reformatting.html

V,=

####Tabulating (assumes you have Tabular)

#####Align assignments

V:Tab /=

#####Colon assignments

V:Tab /: (similar to Align assignments

foo : bar snaf : u

V:Tab /:\zs aligns by value instead i.e.

foo: bar snaf: u

####shortcuts

  • fn-f2 - line number

  • fn-f3 - code nav (tagbar),, ctrl-w right to jump to tagbar

  • fn-f4 - nerdbar (file explorer)

  • fn-f5 - tasklist (add FIXMEs and TODOs to comments

  • ctrl-^ switch windows

  • ctrl-_+b - comment out visually selected block

  • :NERDtree - file explorer

  • % - bracket matching

  • za/zc/zA/zC - un/fold (source: https://www.linux.com/learn/tutorials/442438-vim-tips-folding-fun)

####snipmate shortcuts (how do you make your own?)

  • fun(ction)
  • for
  • for(r improved pattern)
  • (anonymous)f(unction)
  • timeout

####tab completion

  • ctrl-x-o - functions
  • ctrl-x tab - variables

####surround

  • foo => JSON.parse(foo) - JSON.parsef|oo then ys)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment