nkint
nkint

Reputation: 11733

ctags in sublime text

I've just download sublime text 2 beta 2182 under ubuntu 10.10 with Exuberant Ctags 5.8

I want to use it for c++ coding and I need some auto completition and code navigation. (I was used to eclipse with cdt)

I googled and I found ctags a cool tool that can do it, and there is a plugin support for sublime text here.

The problem is that I want create tag file from:

  1. c++ standard lib (std::vector std::map etc)

  2. all classes of the framework i'm using.

Point 1 is (i think) the same of point 2, I just only have to create a tag list of std lib in my /usr/include/c++/4.4.5/

so I've downloaded the plugin and installed it, I made a taglist in this way:

$ cd /absolute_path_of_my_cpp_framework/
$ ctags -R *

I modified /home/me/.config/sublime-text-2/Packages/CTagss/CTags.sublime-settings with this line:

"extra_tag_files" : [".gemtags", "/absolute_path_of_my_cpp_framework/tags"]

Now I open a cpp file, point the cursor on a class name of my framework and used the key binding ctrl+t ctrl+t and nothing happened. Only this message in the bar in the bottom:

can't find "class_name"

Can someone help me?

Upvotes: 30

Views: 11468

Answers (2)

W1M0R
W1M0R

Reputation: 3626

Shell Commands:

$ cd /absolute_path_of_my_cpp_framework/ (1)

$ ctags -R --languages=c++ --langmap=c++:+.inl --fields=+iaS --extra=+q --totals=yes --verbose=yes (2)

$ ctags -a -R --languages=c++ /usr/include/c++/4.4.5/ --fields=+iaS --extra=+q --totals=yes --verbose=yes (3)

$ subl . (4)

Description:

(1) Go to the root folder of your project to ensure that the tags file will be created there.

(2) Generate a new tags file for all C++ files in your project, adding support for .inl files, inheritance, access modifiers, class-qualified scoping etc.

(3) Append tags for the C++ standard lib headers to your generated tags file.

(4) Open the folder in Sublime Text.

References:

  1. http://ctags.sourceforge.net/ctags.html
  2. https://www.chromium.org/developers/sublime-text
  3. http://www.tarosys.com/2014/07/adding-another-file-type-for-ctags.html
  4. Exuberant ctags exclude directories
  5. Vim and Ctags: Ignoring certain files while generating tags
  6. https://www.topbug.net/blog/2012/03/17/generate-ctags-files-for-c-slash-c-plus-plus-source-files-and-all-of-their-included-header-files/

Upvotes: 2

Matt Kline
Matt Kline

Reputation: 10507

I don't personally use Sublime Text, but assuming it uses tag files in a similar manner to vim, you need to generate additional info for C++ completion.

Use ctags with the following options:

ctags -R --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++

Info was taken from this article, which also supplies copies of the standard library headers that you can use to generate tags.

Upvotes: 7

Related Questions