http://ctags.sourceforge.net follow this url for installation and documentation.
We can ctags
lots of programming languages. Here is how to do it for ruby/rails. I really like how RubyMine
jumps to the source code (either withing project score or to the gem source). This is really useful for reading
source code for those classes, methods, modules etc. But Now that I use vim
as My IDE/Editor I really like that
functionality to happen in my vim
editor. And I found ctags
as the solution.
NOTE: you can use
ctags
oretags
foremacs
too ;)
Generate ctags for our project
goto root of your project and generate ctags. `$(bundle list --paths) will tags our gems :) .
ctags -R --languages=ruby --exclude=.git --exclude=log --exclude=tmp . $(bundle list --paths)
It will generate ctags
in our root directory, we can add it to .gitignore
if we want.
Now open your project in vim
and then you can jump to source definition by doing :tags has_many
and ctags
will open /path/to/associations.rb
file and put our cursor in has_many(...)
function definition. Wow!!
But wait, we can also quickly jump to those method definitions from our model/controller etc directly by moving
our cursor to the (anywhere in has_many
in our model) and then press C-]
. Isn't that cool ;)
Generate ctags for node js application
Lets say we wanna generate ctags for node applications e.g: ember app, react app, angular app or any node apps. We can do that by NOT IGNORING node_modules directory.
ctags -R --exclude.git --exclude=tmp .
It will generate ctags for our current node application including node_modules/ or bower_components/ directory.
Now we can jump to any method definitions using C-]