Question

Recently I've been trying my hand at using vim instead of TextMate and one of the features that I've missed most in VIM is TextMate's jump to method function (CMD + Shift + T for those who don't know). From looking around I havn't seen any particular way to emulate this functionality and was wondering if anyone here has had experience with this sort of functionality in VIM.

Thanks in advance for any answers

Patrick

Was it helpful?

Solution

You're looking for vim's 'tags' functionality ... I answered a similar question about tags here: How to implement own tag jump in VIM with CTRL-]?

OTHER TIPS

This functionality has been implemented in fuzzyfinder using :FufBufferTag. See the ticket

I'd love to hear good suggestions as I use Vim all the time but haven't used TextMate. I do the following things which slightly overlap.

  1. Search for d-e-f-space-<first few letters of function name>. So to go to function foo (in Python or Ruby, and within the same file of course), I type /def fo and I'm there. I also have incremental search enabled in Vim.

  2. Use marks for functions which I visit often. So I'll ma at the function definition and then 'a back to it later. I know it's not function definitions but it is a crutch.

you can create a tags file with ctags http://ctags.sourceforge.net/ basically $ctags -R Then once you're in vim :set tags=/path/to/tagsfile

this will also be any tag so not just class names, methods, etc. In normal mode ctrl-] on the method/class/ and it will jump to that position.

You can also use the taglist plugin which will display current tags in a side window. ctags

I had pretty much the same problem and I found a quick and dirty solution (paste this in your .vimrc and call by typing :LS)

function! s:ListFunctions()
vimgrep /function/j %
copen
endfunction
command! -bar -narg=0 LS call s:ListFunctions()

If you require more functionality then Exuberant Ctags will do better for you

I'm using CommandT for file searching, then / to search for a particular function. However, the real issue is with CSS. Cmd Shift T in Textmate enable quick jumps to a particular CSS class, and that is a huge time-saver.

CTags doesn't support CSS parsing, unless you re-compile with a patch (found via google), but I'm not even sure if we can do fuzzy searching for CSS classes like in Textmate. I really miss the Cmd Shift T feature.

I've written a TextMate Bundle command (you can easily assign it to Ctrl+] for example) that lookup for the definition of the class or method under the caret and displays it in a tooltip, along with the file name and the line where it was find.

Check it out: Add a shortcut to TextMate to lookup a class or method definition in a tooltip
Hope you'll find it useful!

The feature described in this question has many different names depending on the IDE/Editor:

  • In Resharper it's called "Goto File member"
  • In Sublime Text 2 it's called "Goto Symbol"
  • In PyCharm it's called "Goto Symbol"

The feature is essentially the same though in all of the above implementations (and I assume it's very similar in TextMate as well). The feature brings up an interactive list of methods/functions (and potentially also includes member variables/properties).

The list allows interactive filtering by typing the name of a methods/functions/etc. The list also usually allows the use of arrow keys to select a method/function/etc. Hitting the enter key with a method/function/etc selected navigates to the line in the current file where the selected method/function/etc is defined.

Of all the existing answers in this question the only one that I see which seems to provide a reasonably similar implementation of this feature is to use the command:

:FufBufferTag 

in vim's FuzzyFinder plugin.

The answer which suggests using the taglist plugin is not a good solution, because the functionality offered by the taglist plugin is quite different from the feature. The taglist plugin offers similar functionality - the ability to view an outline of methods in the currently file, but it does not offer an interactive way to filter that list in realtime. The taglist plugin does allow you to search the tag buffer, but that's not nearly as convenient as the "Goto symbol" functionality offered in other editors.

I wanted to provide an alternative suggestion here, which is to use the command:

:CtrlPBufTag 

in the excellent Ctrlp vim plugin. In my opinion this by far the best implementation of the "Goto Symbol" feature currently available in vim.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top