Sublime Text 3 Multiline Method Folding

断了今生、忘了曾经 提交于 2021-02-07 14:29:24

问题


SO...

Sublime Text has the built in ability to fold methods, but as soon as the method declaration spans multiple lines it loses this ability. Does anyone know about a plugin or a way to make this work? Specifically I am running into this with ruby (and my team adheres to a strict style guide regarding line length), but the language shouldn't matter.


回答1:


Instead of clicking on the down arrow that appears in the gutter next to the first line of the function definition, all you need to do is put your cursor on one of the function's indented lines (not the indented function parameters, but in the function definition itself) and use the CtrlShift[ key binding (on OS X use Alt[) to fold the function and its parameters. Use CtrlShift] (Alt] on OS X) to unfold, or you can click the sideways arrow next to the def line.

So, this:

becomes this:




回答2:


Try this formatting

def example(   # <--- folds parameters here
  param, 
  param
)              # <--- folds method body here
  foo
  bar
  qux
end

The language does matter as far as I know, method folding is part of the language specific configuration. At least it used to be in previous versions.



来源:https://stackoverflow.com/questions/41558450/sublime-text-3-multiline-method-folding

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