tags:

views:

623

answers:

6

Hi guys,

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

A: 

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.

jhs
wasn’t aware of vim's marking functionality. it's great consistently finding new things in vim that can really speed up your workflow
Patrick O'Doherty
+3  A: 

You're looking for vim's 'tags' functionality ... I answered a similar question about tags here: http://stackoverflow.com/questions/1580252/how-to-implement-own-tag-jump-in-vim-with-ctrl/

Chris J
A: 

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

Brendon
A: 

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

Plugawy
thanks that worked really well for what I was trying to accomplish.
Patrick O'Doherty
A: 

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.

Alex Le