tags:

views:

1246

answers:

2

I'm specifically interested in tools that can be plugged into Vim to allow CScope-style source browsing (1-2 keystroke commands to locate function definitions, callers, global symbols and so on) for languages besides C/C++ such as Java and C# (since Vim and Cscope already integrate very well for browsing C/C++). I'm not interested in IDE-based tools since I know Microsoft and other vendors already address that space -- I prefer to use Vim for editing and browsing, but but don't know of tools for C# and/or Java that give me the same power as CScope.

The original answer to this question included a pointer to the CSWrapper application which apparently fixes a bug that some users experience integrating Vim and CScope. However, my Vim/CScope installation works fine; I'm just trying to expand the functionality to allow using Vim to edit code in other languages.

A: 

This may be what you're looking for:

http://www.vim.org/scripts/script.php?script_id=1783

You can also mimic some CScope functionality in your own .vimrc file by using the various flavors of map.

Lucas Oman
+1  A: 

CScope does work for Java.

From http://cscope.sourceforge.net/cscope_vim_tutorial.html:

Although Cscope was originally intended only for use with C code, it's actually a very flexible tool that works well with languages like C++ and Java. You can think of it as a generic 'grep' database, with the ability to recognize certain additional constructs like function calls and variable definitions. By default Cscope only parses C, lex, and yacc files (.c, .h, .l, .y) in the current directory (and subdirectories, if you pass the -R flag), and there's currently no way to change that list of file extensions (yes, we ought to change that). So instead you have to make a list of the files that you want to parse, and call it 'cscope.files' (you can call it anything you want if you invoke 'cscope -i foofile'). An easy (and very flexible) way to do this is via the trusty Unix 'find' command:

find . -name '*.java' > cscope.files

Now run 'cscope -b' to rebuild the database (the -b just builds the database without launching the Cscope GUI), and you'll be able to browse all the symbols in your Java files. Apparently there are folks out there using Cscope to browse and edit large volumes of documentation files, which shows how flexible Cscope's parser is.

alps123
JP Lodine