Sublime code-like method browser in Vim
Asked Answered
G

3

5

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.

Gainless answered 4/2, 2013 at 18:24 Comment(1)
Why bother using Vim when Sublime is just so good?Inherit
Q
8

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.

Quizzical answered 4/2, 2013 at 20:18 Comment(4)
CtrlPBufTag was exactly what i was looking for. Thanks! I just mapped it in my vimrc: map <c-m> :CtrlPBufTag<CR>Gainless
Cool, I love CtrlP. I have mapped :CtrlPBufTag to ,T. :CtrlPTag is another gem.Quizzical
:CtrlPBufTag is exactly what i was after, returning from Sublime. Mapped to D-r/C-r.Jaffa
To get CtrlP working, you will need to sudo apt-get install exuberant-ctags (Linux) or brew install ctags (macOS)Ranitta
M
3

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.

Marshallmarshallese answered 5/4, 2013 at 13:1 Comment(0)
S
2

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.

Serious answered 4/2, 2013 at 18:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.