views:

50

answers:

3

how do you make ctags account for class in c++? when i jump to a tag of a function i get to the same name of the function but in a wrong class.

B b; b.init();

and there are

A::init() {} B::init() {}

i put the cursor on init of b.init() and the jump is to A::init() {} instead of B::init() {}.

Note, i didn't use a and b in my code. so this might not work if u run ctags. if it's not a common problem i ca post the actual code.

+1  A: 

I am not aware of any method to do this, as it would require vim to do c++ parsing. In that situation I use :tselect to show the whole list and choose one.

Karl Bielefeldt
+3  A: 

This doesn't solve your original problem, but a mapping such as the following may help:

nnoremap CTRL+] :exe 'tj' expand('<cword>')<CR>

This will at least make CTRL+] show you a selection menu when there are multiple definitions of init().

too much php
A: 

I wrote lh-tags to solve this problem [It will require lh-vim-lib.]

It does not recognize whether b is a A or a B, but it proposes a little GUI to select which tag we want to jump to.

See it as an interactive :tselect. Put the cursor on an identifier and type <c-w><m-down> in normal mode (which is configurable). It also proposes ways to build and update the ctags base on <c-x>ta and on :w given that g:/b:ctags_dirname has been set for the current project.

Luc Hermitte