Sublime Text 3 Multiline Method Folding
Asked Answered
F

2

5

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.

Fixative answered 9/1, 2017 at 23:3 Comment(0)
W
10

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

Woodchuck answered 10/1, 2017 at 17:7 Comment(1)
Perfect, that's even better as I prefer shortcuts and does not require any change to the code, thanks!Fixative
D
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.

Danner answered 10/1, 2017 at 0:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.