Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore struct declarations and consider only definitions in cscope?

Tags:

vim

cscope

I always use vim + cscope to check symbol definition, and I find cscope always take declaration like:

struct sk_buff;

as a definition, which make vim always show a long list files to choose. Indeed, I only want the definition:

struct sk_buff {
  ...
};

Seems ctags can resolve this problem, but can cscope handle this? Or somethings I'm wrong.

I checked the cscope source, and I find it's hard to modify the lex and yacc source from beginning.

like image 947
Sam Liao Avatar asked Jul 24 '09 03:07

Sam Liao


People also ask

How do I stop cscope search?

To exit from cscope interactive prompt, type Ctrl-d . If you just want to rebuild cscope's database, and not invoke cscope's interactive prompt, pass it the -b option.

What is Ctags and cscope?

cscope, ctags, and Vim are powerful tools for reading a lot of code. ctags can be used to take you to the definition of a variable (e.g., a function, variable, or macro). cscope can be used to take you to the call site of a definition (e.g., all function calls, all variable uses, all macro uses).


1 Answers

You are correct, you cannot do this just with cscope.
I use cscope+ctags with vim every day on both small and large projects as well.
I've found the most productive way to use these tools is to use them both from within vim and with the cscope_maps.vim plugin.

This may not help you but it's helped me int he past, check this site for information on using them together. I'll warn you that if you use the cscope_maps.vim plugin you'll probably want to edit it and comment out the "set cscopetag" option.

like image 72
Steve Lazaridis Avatar answered Nov 15 '22 08:11

Steve Lazaridis