Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime Text 3 Multiline Method Folding

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.

like image 357
Lane Avatar asked Jan 09 '17 23:01

Lane


2 Answers

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:

code before folding

becomes this:

code after folding

like image 141
MattDMo Avatar answered Nov 15 '22 03:11

MattDMo


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.

like image 22
akuhn Avatar answered Nov 15 '22 04:11

akuhn