Sublime code-like method browser in Vim

余生颓废 提交于 2019-12-05 01:34:43

问题


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.


回答1:


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.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/14693020/sublime-code-like-method-browser-in-vim

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!