Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Python-Fold
===========
Better Vim folding for python files.
Installing
----------
Use your preferred vim plugin manager:
* [dein](https://github.com/Shougo/dein.vim)
* [vim-plug](https://github.com/junegunn/vim-plug)
* [vundle](https://github.com/VundleVim/Vundle.vim)
* [pathogen](https://github.com/tpope/vim-pathogen)
Usage
-----
The plugin creates folds starting after 'class' and 'def' (including 'async
def') lines until the last non-blank line before the indent drops to the
same or a lower level than the 'class' or 'def' line itself. The fold level
depends on the nesting of the classes and functions.
Multiline docstrings are also folded. Their level is ALWAYS below the
deepest nested class or function (subject to restriction by the
'foldnestmax' option). This allows all multiline docstrings to be folded
without folding anything else. The easiest way to quickly find the right
level for this is to type (in normal mode) `zRzm`; this (1) sets the level
to the highest value in the buffer then (2) drops it down by one.
If classes or functions contain a docstring the first non-blank line of the
docstring is shown as the fold text, otherwise "[No Docstring]" is shown.
The fold text for multiline docstrings is always the first non-blank line.
Troubleshooting
---------------
To re-initialise the plugin for a buffer (if fold settings were messed with)
run the following command while in the buffer:
```
call folds#python#Enable()
```
Known Problems
--------------
1. The entire buffer is scanned when changes are made, which is slow.
2. On starting vim, fold text is not shown.
3. Code (or what looks like code) in multiline strings will be folded.
4. Class/function recognition is simplistic; for instance a line containing
just `def:` will cause the subsequent lines to be treated as a function.