Taylor M. Hedberg
autoload: Add option to fold away trailing blank lines
|2 weeks ago|
|autoload||2 weeks ago|
|doc||3 years ago|
|ftplugin||3 years ago|
|plugin||3 years ago|
|.gitattributes||8 years ago|
|.gitignore||8 years ago|
|.vintrc.yaml||3 years ago|
|AUTHORS||3 years ago|
|LICENSE||3 years ago|
|README.md||2 weeks ago|
Because of its reliance on significant whitespace rather than explicit block
delimiters, properly folding Python code can be tricky. The Python syntax
definition that comes bundled with Vim doesn’t contain any fold directives at
all, and the simplest workaround is to
set foldmethod=indent, which usually
ends up folding a lot more than you really want it to.
There’s no shortage of Vim plugins for improved Python folding, but most seem to suffer from cobbled-together algorithms with bizarre, intractable bugs in the corner cases. SimpylFold aims to be exactly what its name suggests: simple, correct folding for Python.
It’s nothing more than it needs to be: it properly folds class and function/method definitions, and leaves your loops and conditional blocks untouched. There’s no BS involved: no screwing around with unrelated options (which several of the other plugins do), no choice of algorithms to scratch your head over (there’s only one that’s correct); it just works, simply.
Use one of the following plugin managers:
Also strongly recommend using FastFold due to Vim’s folding being extremely slow by default.
No configuration is necessary. However, there are a few configurable options.
Set variable to
1 to enable or
0 to disable.
For example to enable docstring preview in fold text you can add the
following command to your
let g:SimpylFold_docstring_preview = 1
||Preview docstring in fold text||
||Fold docstrings (buffer local)||
||Fold imports (buffer local)||
||Fold trailing blank lines||
||Fold trailing blanks (buffer)||
There are also a few buffer local commands for fast toggling:
||Enable docstring folding|
||Disable docstring folding|
||Enable import folding|
||Disable import folding|
Use Vim’s built-in folding commands to expand and collapse folds.
The most basic commands are
zc to close a fold and
zo to open one.
:help fold-commands for full documentation.
If you find any bugs, please report them and submit pull requests on GitHub! Simple is nice, but simple and correct is much better.