Sublime Text 3 Multiline Method Folding

1.1k views Asked by At

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.

2

There are 2 answers

1
MattDMo On BEST ANSWER

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

0
akuhn On

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.