开发者

multi tags problem for vim

I found 开发者_开发问答that when multiple tags exist for a given symbol, Vim can't select the right tag . I don't know whether it's always the truth , but at least I met this problem for several times.

To put my problem more clear, let's say there are two classes : class A and class B in two different cpp files. Both of them defined a public member function called AddContext. Then somewhere else in the source code of the project , let's denote it as place x, a instance of A called its memeber function AddContext.

You generate tags for the the project and go to place x and move the cursor under "AddContext" , and finally hit ctr-] .To your dismay, vim jump to the definition of B::AddContext rather than A::AddContext.

So is there any good vim practice to solve the problem as I momentioned ?


Use

:tnext
:tprevious

or

:tn
:tp

This will help to solve your problem in the manual way. Ctags and Vim do not understand the context. So you have to determine it yourself.

Mapping those commands is a good way to deal with the problem.

You also can try 0scan plugin. It can help to choose desired place to jump in a more convenient way. Put your cursor on a symbol and press 0u.


Instead of just pressing ^] use g^]. This will show a menu if there are multiple tags for the identifier under the cursor so you can pick the tag you want to jump to. If you jump to a tag and it's not the right one, you can use the :tselect (you can abbreviate to :ts) to bring up the menu for the last tag you followed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜