Sathish
Sathish

Reputation: 21090

Sublime code-like method browser in Vim

Sublime code has a shortcut Super-R which opens a method browser listing all methods in current class (Ruby). Is there a plugin to get similar functionality in Vim?

"/def " or "m]" work only if you're familiar with the class and know what method you want to go to, whereas Super+R works for just exploring a class.

Upvotes: 5

Views: 3652

Answers (3)

Fatih Arslan
Fatih Arslan

Reputation: 17127

You can use my project https://github.com/fatih/subvim

For cmd+r you can directly jump to any definition on the fly. No need to genarete tags or whatever. Currently any language supported by ctags can use this feature. I've also add languages like Go, Coffeescript, Objective-C,etc... It means just fire it up.

Also it has Sublime-like features backed in (means no plugins necessary). Thus you can use the following shortcuts:

  • cmd + p -> go to anything
  • cmd + t -> go to file
  • cmd + r -> go to symbol
  • cmd + k -> show side bar
  • cmd + / -> toggle comment
  • cmd + [ -> indent
  • cmd + ] -> unindent
  • cmd + <number> -> jump to tab 1, tab 2, ...
  • cmd + alt + left -> move to next tab
  • cmd + alt + right -> move to previos tab
  • cmd + z -> undo
  • cmd + shift + z -> redo
  • cmd + s -> save file
  • cmd + w -> close
  • cmd + f -> search

Also autocompletion, restoring latest session, automatic bracket closing and many minor changes make it really a joy to use.

Upvotes: 3

romainl
romainl

Reputation: 196789

The TagList plugin is another (very popular) option. There are a bunch of others.

FYI, /def and m] are not the equivalent of Sublime Text's Ctrl+R. That would be :tag foo which you can tab-complete if you don't know all the names of your methods.

While we are at it, the CtrlP plugin has a feature very similar to Sublime Text's Ctrl+R: :CtrlpBufTag that I use hundreds of times a day.

All of these methods depend on the presence of a tags file generated by Exuberant Ctags or some compatible program. Actually, tags are quite an important part of the Vim experience.

Upvotes: 8

Steve
Steve

Reputation: 15736

The tagbar plugin works pretty well with Ruby files. Perhaps its not exactly the same as Sublime Super-R but it does give you a quick and easy way to explore a class.

Upvotes: 2

Related Questions