SublimeText2/3 C++ code navigation with CTags

If you are fans of the Sublime Text editor and want to do all/as-much-as-possible of your coding into it - There is a CTags package installable through Package Control, which would give you a GoToDefinition & GoToSymbol functionality.

On OS X, you need to install ctags through Homebrew (the default system version doesn’t provide some features needed by the package)

$ brew install ctags

Then point the CTags SublimeText package to the new version of ctags (Sublime Text -> Preferences -> Package Settings -> CTags -> Settings - User):

{
    "command": "/usr/local/bin/ctags"
}

After you are finished, set the modules of your Projucer project to be copied locally in the project dir (and just add them in .gitignore, if you don’t want them in the repo), open the root dir of the project in Sublime Text and build the tags file - default is Ctrl + T, Ctrl + R. Choose the last option in the list (to traverse the entire dir).

The tags file builds fairly fast and now you can do things like:

  • Set the cursor on a method call or a type name and with 2x Ctrl + T it will navigate to the definition.
  • Do the same thing with any type of class members.
  • It works with includes, too.
  • Jump to previous - Ctrl + T, Ctrl +B.
  • etc. Here is the full list of commands: https://github.com/SublimeText/CTags#commands-listing

There is definitely a way to “transfer” the build to ST, too, but I haven’t touched on that.

I hope this will be helpful to someone.

Cheers!

1 Like

I use CTags with VIM, YouCompleteMe and Syntastic - great combo !

1 Like