I want to go to a symbol (say main) in a given file. Is it possible to restrict the scope of search to given files with cscope?
:cs find s main
Without this, when I look for a symbol like main, I get hundred plus results in my project and I have to identify and type the number like 90 to navigate to the symbol.
The option of going to the file of interest and searching for the symbol using vim search is cumbersome for common words like "main" which may be present a handful of times in the file.
Is it possible to restrict the scope of search to given files with cscope?
No. Cscope itself doesn't let you do that so Vim's cscope integration doesn't either.
If you want to get out of this specific hole, you may have to ponder a few things…
Is The tool you are using the right tool if it doesn't do what you want?
Why, exactly, do you want to jump to that specific main()
in that specific file? What do you do next?
The way I see it, jumping to a main()
doesn't seem to serve any purpose in and of itself as it is usually an entry point. As such, "jump to main()
in foo.c
" is not much better than "jump to foo.c
". It seems to be just another intermediary step.
Is there another way to do exactly that?
Should I abandon that workflow in favour of a better one?
If you know there is a main()
in foo.c
, there are a few simpler alternatives to cscope, like:
:grep main foo.c
or:
:find +/main foo.c