Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 670
Sathish Avatar asked Feb 04 '13 18:02

Sathish


People also ask

Is vim better than sublime text?

In our opinion, Sublime text is best for normal text editing, and Vim is best for coding and documentation-related work.

Does Sublime Text have vim?

Understanding vi editorSublime includes vim, which is an advanced section of vi editor, and includes customization of macros, snippets and plugins.

Can I use sublime as IDE?

Sublime can be used on Linux, Windows and Mac as an IDE for developing Chromium. Here's what works: Editing code works well (especially if you're used to it and get used to the shortcuts). Navigating around the code works well.

How do I run Sublime Text?

To run code in Sublime Text, go to Tools > Build System, and select the language for your code (Sublime comes with support for various languages like Python, Ruby, Bash, and more). Next, press Cmd+B on Mac or Ctrl+B on Windows to run your code.


3 Answers

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.

like image 141
romainl Avatar answered Oct 21 '22 09:10

romainl


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.

like image 25
Fatih Arslan Avatar answered Oct 21 '22 08:10

Fatih Arslan


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.

like image 35
Steve Avatar answered Oct 21 '22 09:10

Steve