Ctag doesn't generate tags file

I’m watching Ben Orensteins ‘Vim for Rails Developers’ video. To generate the tags file he runs this command in the terminal:

ctags -R --exclude=.git --exclude=log *

However when I run this command in my terminal, I get:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ctags: illegal option -- R
usage: ctags [-BFadtuwvx] [-f tagsfile] file ...

Does anyone have an idea what’s going on?

thanks for your help,

Anthony

Try following these instructions. Although you might need to replace the .bashrc with the shell of yourchoice if you are using anything other than bash.

2 Likes

Thanks a lot Frank, that solved the problem. Tags file for my project is generated now.

greetings,

Anthony

It looks like you’re running the wrong version of Ctags. I would make sure you’re installing it from Homebrew and that when you type which ctags that the one in your Homebrew path shows up.

Agreed. This is likely it.

@Geof , @Ben , yeah, like I said to Frank, reinstalling the latest version of CTags with Homebrew solved the issue.

Can I only jump to methods I wrote myself, or can I also jump to methods of the framework. For instance, when I want to check Active Records’ update_attributes method, I get:

E426: tag not found: update_attributes

greetings,

Anthony

If you have access to screencasts through Prime (which I think all forum-enabled plans do), Drew Neil, the author of Vimcasts, has a screencast here on Learn where he describes how to include tags for gems and/or the standard library in your tags. I’m going to sum up that video quicky here because I just caffeinated and have nothing better to do this early in the morning.

I’m using the approach, and it’s pretty awesomesauce. If you’re an rbenv user (and you really should be, if I’m going to stand on my soapbox for a moment), you can index the standard library whenever you install a new version of ruby with vim hero/celebrity/benevolent dictator/philosopher king Tim Pope’s rbenv-ctags. Then I index gems using gem-ctags, also written by the aforementioned Tim Pope.

I think that solves your problem, but I’d also recommend having ctags get automatically built whenever you git commit using a solution devised by some guy named Tim Pope (seeing a pattern here?) that he documents in his blog: tbaggery - Effortless Ctags with Git

Hope this helps!

1 Like

Oh, and you might need to follow the instructions in those two Git repos’ README.md files regarding load path and/or bundler/rbenv vim plugins in order to be sure that those tags get pulled in to your project, or else you’ll be generating tags and then not actually seeing them in vim.