Source lookup for word under cursor

1 view
Skip to first unread message

Ben Rady

unread,
Feb 9, 2010, 7:46:06 PM2/9/10
to vimchicago
I've been messing around with a way to quickly lookup source from vim. What I've got here is something that will pull the current word under the cursor when you hit <leader>v (my leader key is comma) and use the gem command to find the corresponding file in a gem. It then opens that file in a new tab. It falls down in a few places, but it's a good start.

function! OpenRubySource()
  let class_name = expand("<cword>")
  let ruby_file = system("gem which ".class_name)
  exec "tabe ".ruby_file
endfunction

nmap <Leader>v :call OpenRubySource()<cr>

Is there already a plugin that does something like this? I did some searching before diving into this but I didn't find anything.

Ben

Jim Breen

unread,
Feb 23, 2010, 1:19:40 AM2/23/10
to vimch...@googlegroups.com
Ben,

Have you taken a look at ctags?  It's a very mature tagging tool with a vim plugin.  Here's a few links related to using it in vim with ruby (which I haven't personally done).

http://vimeo.com/3989493 "Creating ctags with git"
http://vimeo.com/4007386 "Using ctags in vim"

Jim
Reply all
Reply to author
Forward
0 new messages