Control redraws

19 views
Skip to first unread message

John Passaro

unread,
Jan 17, 2017, 5:53:20 PM1/17/17
to vim...@googlegroups.com
Hi list,

I frequently use commands like ':move+1' via shortcuts (thanks tpope/vim-unimpaired !). I've noticed that when I have folds on, after the :move command, all folds in sight tend to be closed.

My hypothesis is that the :move command somehow triggers something like the zX command (i.e. undo manual foldopens/closes, reapply foldlevel, recalculate folds), and since my foldlevel is usually 0 this causes all the folds to be closed.

Does anything document this? Are there other commands for which this also happens? Most importantly: is there any way to control it? It's a bit of a hindrance having to re-open the fold I'm in; it would be nice if this process would at least do something like zv after the folds are recalculated, or zx instead of zX.

Usually the help files are very informative, but what I've found doesn't quite explain this behavior. For what it's worth, I looked at :autocmd TextChanged but it outputs nothing.

Thanks in advance for any pointers!

John Passaro

P.S. Here's a reproducible example. On the following text, built-in html syntax creates folds from lines 1-5 and 8-12:
<div
    id="you"
    title="thing"
    class="hello"
    >
</div>

<div
    id="you2"
    title="person"
    class="hello"
    >
</div>

I open both folds and type :3move4. The text changes as expected but suddenly both folds are closed again. This happens when I open without vimrc so I know it's not one of my settings. The command without vimrc is a little unusual, in case you want to reproduce:
vim -u NONE +"syntax on" +"set fdm=syntax" +"e fold_example.html"

John Passaro

unread,
Jan 18, 2017, 8:59:02 PM1/18/17
to vim...@googlegroups.com
For what it's worth, this appears to have been reported on the vim github as an issue. They weighed "feature or bug?" and decided on the former. https://github.com/vim/vim/issues/536

That also pointed to the most effective workaround I found: managed to augment my mappings by first doing :set fdm=manual, then afterward doing :set fdm=expr (or syntax as the case may be). It still has to recalculate the folds which causes a visible pause, but this is for sure a big improvement.
Reply all
Reply to author
Forward
0 new messages