views:

184

answers:

4

On Railcasts I have noticed a very interesting feature 'Go to symbol' window. It work like Command-T but shows available classes and methods in current file. How to get it in vim?

+3  A: 

Try

:help tags

There are various programs and scripts around that will generate tag files. Also, the tag file format is really simple, so its easy to throw together a sed(1) or some such script that will generate a tag file from whatever language you are working in.

The key to easily getting a tag file (besides just downloading a generator) is to key on formatting style rather than actually parsing syntax.

DigitalRoss
A: 

Try the Command-T VIM plugin.

The Command-T plug-in for VIM provides an extremely fast, intuitive mechanism for opening files with a minimal number of keystrokes. It's named "Command-T" because it is inspired by the "Go to File" window bound to Command-T in TextMate.

Files are selected by typing characters that appear in their paths, and are ordered by an algorithm which knows that characters that appear in certain locations (for example, immediately after a path separator) should be given more weight.

Or you might also like PeepOpen.

PeepOpen is a file navigation application that works with TextMate, Coda, MacVim, and Emacs (Mac OS X Snow Leopard on 64-bit Intel required, support for other editors is coming soon). Search on both paths and filenames, and easily open the file in your text editor with a single keypress. Useful metadata helps you quickly choose the file you’re looking for.

marshally
+1  A: 

Also it's worth adding exuberant ctags to the mix http://ctags.sourceforge.net/. This will parse loads of languages including ruby and generate your tags file for you and save you from the sed bit.

ctags -R 

Will do the trick. Also see the excellent Taglist plugin for a sidebar listing all tags in the currently open buffers:

http://vim-taglist.sourceforge.net/

Ben
A: 

The version of ctags that comes pre-installed on every OS X 10.6 (Snow Leopard) installation dates 1993.

Download, compile, and install the newest version from http://ctags.sourceforge.net/. This will save much unnecessary headaches (like the 1993 version not support Java syntax, because Java was not yet invented. This is the same for many newer languages.)

After installation, use the ctags -R * command to recursively work through your source code and create a tags file (by default named tags) in your current working directory.

VIM will parse this tags file. Move the cursor over a function/method call, press <Ctrl> + ] and VIM opens up the file containing the method/function body matching the text under the cursor. In order to return to the previous file, press <Ctrl> + t, and VIM swaps its current buffer to the file from which we originally jumped.

Just as DigitalRoss suggested, reading VIM's built-in help documentation will give you a more in-depth understanding of just how powerful ctags are. Use this command to read the documentation:

:help tags
Sean