5

I use vim-rails and ctags for navigate of methods. For it I run ctags -R * in /home/***/.rvm/gems/ruby***/gems. But in this directory was many folders for one gems just different versions(for example activerecord v. 3.0.7/3.1.3/3.2.2/3.2.3). And when I try go to(ctrl+]) method I get to old version. How I can run ctags only with latest gems version?

3 Answers 3

12

You can make bundler show the locations for the gems in the gemfile with

bundle show --paths

If you pipe this list into ctags I think you will have what you need.

bundle show --paths | xargs ctags -R

edit: Summarized in this blogpost: http://heim.no/VIM/2012/04/19/generate-ctags-for-all-bundled-gems-in-a-ruby-project/

4
  • Andreas, thanks for the info. I posted this question on your blog a few months ago but haven't gotten around it: I've found a problem in that, I can only go to the tags when I'm originating from a file in my project. Once I'm in a file that is contained in one of the gems I'm using, I can't follow any of the methods called in that file to it's method definition. I believe it's because it doesn't know how to find the ctags file relative to the file I'm currently browsing. Have you had any problems like I'm seeing?
    – Tonys
    Aug 31, 2012 at 3:28
  • Tony, seems like I actually have to check this out a bit and post an update (as I said a couple of months ago) :) Sep 11, 2012 at 8:27
  • 1
    This is great. But it generates ctags only for gems. How do i make it generate for both gems and current project?
    – Sathish
    Feb 23, 2013 at 18:58
  • @Sathish I posted answer to this below Aug 10, 2018 at 3:15
1

If you want to add tags for your project along with the gemfile tags you can use -a option to append so you can just do:

ctags -R -f .tags && bundle show --paths | xargs ctags -R -a -f .tags
0

Work-around: I'm not sure of a direct method, but you always have the option of editing the "tags" file manually, search/replace for all older gems versions and delete them or maybe delete all gems related sections and later on you can append to the tags file using [ctags -a 3.2.3]

1
  • Yes, I know. But tags file has more than 63000 rows and editing manually is not good idea. And remove all gems expect for the latest version is not good idea too, because I may need later older gems version. My first question is not correct. How I can use gems version which used in Gemfile?
    – Eugene
    Apr 13, 2012 at 8:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.