Tag search

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Tag search

Kiem Lam
Hello,

Thanks to tags, I am able to quickly find the definition of any
expression. But is there a way to do some kind of reverse operation? I
would like to find where the expression under my cursor is used (in
all my source files). The result of such an operation might return a
lot of locations and I would like to jump easily to one of the listed
locations (and go back).

Does anybody use that kind of searching tool?

Thanks,

--
Kiem Lam
Reply | Threaded
Open this post in threaded view
|

Re: Tag search

Yegappan Lakshmanan
Hi Kiem,

On 11/8/05, Kiem Lam <[hidden email]> wrote:

> Hello,
>
> Thanks to tags, I am able to quickly find the definition of any
> expression. But is there a way to do some kind of reverse operation? I
> would like to find where the expression under my cursor is used (in
> all my source files). The result of such an operation might return a
> lot of locations and I would like to jump easily to one of the listed
> locations (and go back).
>
> Does anybody use that kind of searching tool?
>

You can use either cscope (cscope.sf.net) or GNU id-utils
to list all the locations where a keyword is used.
Using GNU id-utils, you can search thousands of files
in a few seconds.

- Yegappan
Reply | Threaded
Open this post in threaded view
|

Re: Tag search

Mathias Michaelis
In reply to this post by Kiem Lam
Hello Kiem

> I would like to find where the expression under my cursor is used
>
A simple way (should work on windows and linux):

:grep <cword> *.c *.h
:copen

HTH
Mathias
Reply | Threaded
Open this post in threaded view
|

RE: Tag search

David Fishburn
In reply to this post by Kiem Lam
 

> -----Original Message-----
> From: Kiem Lam [mailto:[hidden email]]
> Sent: Tuesday, November 08, 2005 9:25 PM
>
> Thanks to tags, I am able to quickly find the definition of
> any expression. But is there a way to do some kind of reverse
> operation? I would like to find where the expression under my
> cursor is used (in all my source files). The result of such
> an operation might return a lot of locations and I would like
> to jump easily to one of the listed locations (and go back).

I also use cscope for this.
I find it very fast, you just had to "build" the cscope database prior to
using it.

If you are using C/C++ then it understands the code and knows who is calling
who.

But I also use it for SQL, since it makes navigation very quick and
effective.  In that case though, it doesn't understand the calling
conventions.  

These are the settings I use in my vimrc.
The IF block will automatically load the cscope database if I launch Vim
from a directory with it in.

I have much, much more around the usage of it including maps and functions.

    " If 'csto' is set to zero, cscope database(s) are searched first,
    " followed " by tag file(s) if cscope did not return any matches.
    set cscopetagorder=0
    " set cscopetag
    set nocscopeverbose
    " determines how many components of a file's path to display
    set cscopepathcomp=3
    " Use the quickfix window for the cscope query
    set cscopequickfix=s-,c-,d-,i-,t-,e-
    " add any database in current directory
   
    if filereadable("cscope.out")
        " cscope -C (queries this with case insensitivity)
        exec 'cs add '.expand('%:p:h').'\cscope.out ""
'.g:cscope_options_default
        " else add database pointed to by environment
    elseif $CSCOPE_DB != ""
        cs add $CSCOPE_DB
    endif
    set csverb


--
Do you use Vim to edit SQL?
<Plug>
Check the description of these plugins:
dbext.vim - Provides database access to 10 databases (Oracle, Sybase, SQL
Server, MySQL,...) (http://www.vim.org/scripts/script.php?script_id=356)
SQLUtilities - Formatting SQL, generate - columns lists, procedures for
databases (http://www.vim.org/scripts/script.php?script_id=492)
sql.vim - SQL indent file for Sybase ASA and Oracle
(http://www.vim.org/scripts/script.php?script_id=495)
Intellisense for Vim : SQL, C++, CSharp, Java, JSP, XML, HTML
(http://www.vim.org/scripts/script.php?script_id=747)
</Plug>


Reply | Threaded
Open this post in threaded view
|

Re: Tag search

Kiem Lam
Hello,

Thanks for your answers! As I only use C, I will give cScope a try!

Kiêm

On 11/9/05, David Fishburn <[hidden email]> wrote:

>
>
> > -----Original Message-----
> > From: Kiem Lam [mailto:[hidden email]]
> > Sent: Tuesday, November 08, 2005 9:25 PM
> >
> > Thanks to tags, I am able to quickly find the definition of
> > any expression. But is there a way to do some kind of reverse
> > operation? I would like to find where the expression under my
> > cursor is used (in all my source files). The result of such
> > an operation might return a lot of locations and I would like
> > to jump easily to one of the listed locations (and go back).
>
> I also use cscope for this.
> I find it very fast, you just had to "build" the cscope database prior to
> using it.
>
> If you are using C/C++ then it understands the code and knows who is calling
> who.
>
> But I also use it for SQL, since it makes navigation very quick and
> effective.  In that case though, it doesn't understand the calling
> conventions.
>
> These are the settings I use in my vimrc.
> The IF block will automatically load the cscope database if I launch Vim
> from a directory with it in.
>
> I have much, much more around the usage of it including maps and functions.
>
>     " If 'csto' is set to zero, cscope database(s) are searched first,
>     " followed " by tag file(s) if cscope did not return any matches.
>     set cscopetagorder=0
>     " set cscopetag
>     set nocscopeverbose
>     " determines how many components of a file's path to display
>     set cscopepathcomp=3
>     " Use the quickfix window for the cscope query
>     set cscopequickfix=s-,c-,d-,i-,t-,e-
>     " add any database in current directory
>
>     if filereadable("cscope.out")
>         " cscope -C (queries this with case insensitivity)
>         exec 'cs add '.expand('%:p:h').'\cscope.out ""
> '.g:cscope_options_default
>         " else add database pointed to by environment
>     elseif $CSCOPE_DB != ""
>         cs add $CSCOPE_DB
>     endif
>     set csverb
>
>
> --
> Do you use Vim to edit SQL?
> <Plug>
> Check the description of these plugins:
> dbext.vim - Provides database access to 10 databases (Oracle, Sybase, SQL
> Server, MySQL,...) (http://www.vim.org/scripts/script.php?script_id=356)
> SQLUtilities - Formatting SQL, generate - columns lists, procedures for
> databases (http://www.vim.org/scripts/script.php?script_id=492)
> sql.vim - SQL indent file for Sybase ASA and Oracle
> (http://www.vim.org/scripts/script.php?script_id=495)
> Intellisense for Vim : SQL, C++, CSharp, Java, JSP, XML, HTML
> (http://www.vim.org/scripts/script.php?script_id=747)
> </Plug>
>
>
>



--
Kiem Lam