Skip to content

Instantly share code, notes, and snippets.

@gangleton
Forked from ren/gist:913576
Created April 12, 2011 15:05
Show Gist options
  • Save gangleton/915668 to your computer and use it in GitHub Desktop.
Save gangleton/915668 to your computer and use it in GitHub Desktop.

Vim for Rails Developers

http://www.codeulatescreencasts.com/products/vim-for-rails-developers

Intro

rails.vim

  • Rfind (w/ tab completion)
  • gf (go to file under cursor)
  • Runittest Rcontroller Rfunctionaltest
  • RVunittest (vertical split)
  • RSunittest (horizontal split)
  • RTunittest (new tab)
  • Rake (run tests)
  • Rgenerate migration add_foo_to_bar

snipMate

  • def + tab (new method): set method name, hit tab again
  • sel + tab, map + tab
  • .vim/bundle/snipmate.vim/snippets/ruby.snippets
  • New snippets in .vim/snippets

ragtag

Mapping (cursor = ^) ~

  • <C-X>= foo<%= ^ %>
  • <C-X>+ <%= foo^ %>
  • <C-X>- foo<% ^ %>
  • <C-X>_ <% foo^ %>
  • <C-X>' foo<%# ^ %>
  • <C-X>" <%# foo^ %>
  • <C-X><Space> <foo>^</foo>
  • <C-X><CR> <foo>\n^\n</foo>
  • <C-X>/ Last HTML tag closed
  • <C-X>@ <link rel="stylesheet" ...>
  • <C-X># <meta http-equiv="Content-Type" ... />
  • <C-X>$ <script src="/javascripts/^.js"></script>

ctags

  • Install w/ homebrew, default is crap
  • Had to change path to get HB version first
  • ctags -R --exclude=.git --exclude=log --exclude=tmp *
  • set tags=./tags
  • ctrl + ] (jump to definition)
  • tag /validates_presence_.* (enter number to jump) ((doesn't work as expected))

ack

  • ack --ruby controller
  • .ackrc w/ --ignore-dir=rails (ignore rails directory)
  • set grepprg=ack, then grep --ruby controller
  • :cn (next result), :cp (prev result)

Extras

  • yss " wrap line inside double quotes

  • ysiw[ wrap word in brackets

  • ci" change inside double quotes

  • da" delete around double quotes

  • daw delete around word (delete whole word)

  • gi go to where you were last inserting

  • ctrl + o go back one jump

  • ctrl + i go forward one jump

  • https://github.com/r00k/dotfiles (git blame macro)

  • tComment - another comment option

##For closing HTML/XML tags easily:

http://vim.sourceforge.net/scripts/script.php?script_id=301

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