Find all kinds of method use in vim

Is there a way to find all kinds of method use in vim? I am using vim as an IDE for Rails with rails.vim. ctags helps move on to defining a method from use, but not vice versa AFAIK. I would like to find everywhere (controllers, views, etc.) that the method was used.

+6
source share
2 answers

There are no perfect solutions in Vim, but you can come close to cscope and grep or ack .

cscope helps you find all references to a character. It was created for the C and C languages, but it also does a decent job of matching characters in Ruby code. He will not constantly get context.

Here's a vim cscope tutorial and a blog post about Ruby / Vim / cscope and another blog post , both of which include additional tips on navigating Ruby / Rails in Vim.

Using grep or ack from Vim with fastfix integration is another great way to find characters. They have no concept of scope / context, but often a simple search is enough. Using only the built-in command :grep , you can do:

 :grep some_method app/controllers :cwindow 

And get the search results in the quickfix window, which allows you to quickly jump to matching files and line numbers.

A much better option is the ack.vim plugin, which integrates ack with Vim and uses quickfix windows.

If you are not already using the CTAGS navigation plugin, I recommend Tagbar .

+7
source

I wrote a gem to do just that: https://rubygems.org/gems/starscope

It correctly parses ruby ​​code and exports file formats to ctags and cscope.

+5
source

All Articles