better use of ctags

105 views
Skip to first unread message

alex

unread,
Jun 14, 2009, 7:53:35 AM6/14/09
to vim_dev
I know about taglist and omnicppcomplete plugins, but both are not
enough, in my opinion, for making working with vim + ctags real
powerfull.

It would be a simple task to write a python program for "searching and
navigating" a tags file !

Within vim, or from the bash, it would be possible to extract
information from a tags file generated with exuberant ctags, running
the python script, so that large projects could easily be handled.

For example it should be possible to list all the classes that much a
given query (formulated with regular expressions) AND/OR all the
function members that much a given query and so on.

From the bash, for example, this could be something like

tagsmanager --file=./tags --name='a+' --class='abc*|def' --
function='abc*' --kind='s'

the output should be the list of all structs that begins with an 'a',
defined within a function that begins with abc member of a class that
begins with abc or of the class def. The search would be in the tags
file in the current directory.

(another simple example colud be:
tagsmanager --file=./tags --name='abcd*' --kind='c'
that sould lists all tha classes that begins with abcd in the project
relative to the ./tags file
and so on...)

The output list should be "navigable" and it should be possible to go
to the definition with vim
"or something like this"...

A simple python script would be very usefull for achieving this
powerfull results...

What do you think ?
Best regards,
THX

Ben Fritz

unread,
Jun 14, 2009, 11:37:28 AM6/14/09
to vim_dev
I think it's worth a shot, but I'd try cscope first to see if that's
what you want. I haven't tried it yet (it's on my TO DO list) but you
description basically sounds like one of the many use cases of cscope.

alex

unread,
Jun 14, 2009, 12:59:20 PM6/14/09
to vim_dev
Yes, but cscope is only for C !

Not even for object oriented C++.

I have tried global too, but without too much enthusiasm.

ctags is the better program for generating tags files, and supports a
lot of languages, including obviously C++ and other "major" object
oriented languages...

THX

Dominique Pellé

unread,
Jun 14, 2009, 2:52:46 PM6/14/09
to vim...@googlegroups.com
alex wrote:


cscope works with c++ too. I'm using it on c++ code.

Cscope and ctags have their respective pros & cons.

cscope does things that ctags does not do. ctags only
finds where things are defined. cscope does that as well,
but can also search for other things. From ":cscope help":

c: Find functions calling this function
d: Find functions called by this function
e: Find this egrep pattern
f: Find this file
g: Find this definition
i: Find files #including this file
s: Find this C symbol
t: Find assignments to

On the other hand, ctags knows more about c++
and works nicely with the omnicppcomplete plugin.

So you should consider using both if you write c++ code
with Vim.

Neither cscope or ctags handle well overloaded functions
though. They cannot guess to which one to jump to when
several functions have the same name.

Cheers
-- Dominique

Reply all
Reply to author
Forward
0 new messages