How can I fold all the methods in a Python class? I use Evil and would prefer a pure Evil solution, if possible.
I'm looking for a quick way to take something like this:
class LongClassIDidNotWrite():
def method1():
junk...
junk...
junk...
def method2():
junk...
junk...
junk...
def method3():
junk...
junk...
junk...
and make it look like this:
class LongClassIDidNotWrite():
def method1():
def method2():
def method3():
I don't care if it has a ...
at the end of the line or has a pretty {{{}}}
notation telling me the number of lines folded. I just want it to fold!
I know I can press zc
within a method to fold it. If I try something like VGzc
, it doesn't fold. The fastest thing I've come up with is to record a macro qazc]]q
and then replay it doing something like 100@a
.
Looking at how Vim does it, posts say to :set foldmethod=indent
. To which Evil says,
"State foldmethod=indent cannot be set as initial Evil state".
I've tried vimish-fold
, along with evil-vimish-fold
as well as origami
. I can't get them to fold the methods within a class like above. They supposedly "just work". But that's not what I'm experiencing. Before I waste more time doing trial-and-error and scrounging, is there something I'm missing? It seems like this problem would be solved already.
class ...
line,hs-hide-level
will collapse everything with in the class, giving you your requested output. This would be unlikehs-hide-block
which would collapse the entire class to one line.