Skip to content

Instantly share code, notes, and snippets.

@cloud8421
Created September 18, 2012 14:36
Show Gist options
  • Save cloud8421/3743468 to your computer and use it in GitHub Desktop.
Save cloud8421/3743468 to your computer and use it in GitHub Desktop.
Vim and Tmux workshop - 05 - Working with Rails

Working with Rails tips and tricks

Navigation

  • Pressing gf is usually a good shortcut to open a file:
    • on model names (as symbols or class names) will take you to the file
    • on partial calls it will open the partial
  • Pressing :R<tab> will give you all available commands
  • :R commands can be customized, see these custom extensions for Backbone

Tags

To use CTags in Vim, it's enough to run the command from the project root

/usr/local/bin/ctags -R --exclude=.git --exclude=log --exclude='*.js' --exclude=public --exclude=tmp -f ./.tags *

Note that the homebrew version is being used here.

It's also good to set the right settings in Vim:

" Tags
let Tlist_Ctags_Cmd = "/usr/local/bin/ctags -R --exclude=.git --exclude=log --exclude='*.js' -f ./.tags *"
set tags+=.tags"

Both settings assume a .tags file inside the project, which you can add to .gitignore

Tag navigation can be activated by pressing ctrl-] on a method, typing :ta query or using ctrl-p tag search.

Tags are useful with jumps, a typical workflow can be pressing ctrl-] on a cucumber step to see its definition, then pressing ctrl-o to go back to the feature file.

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