Michael Gundlach
Michael Gundlach

Reputation: 109323

How do I make Python folding in vim not visually ruin the whitespace?

When I fold Python code in vim, the fold text always starts in column zero. This is visually noisy since Python has significant whitespace -- it looks like top-level code when I glance through the file.

Is there a setting to tell the foldtext to indent itself to the level of the first line of code being folded, short of rewriting the foldtext() method?

Upvotes: 9

Views: 164

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172510

The way to influence this is through the 'foldtext' option.

Here's a simple example to get you started:

:setlocal foldtext=repeat('\ ',indent(v:foldstart)).foldtext()

Upvotes: 5

Related Questions