Re: [vim/vim] long lines automatically become foldable even with set nowrap (Issue #21000)
cjxgm (Vim Github Repository) <[email protected]>
| Newsgroups | gmane.editors.vim.devel |
|---|---|
| Message-ID | <vim/vim/issues/21000/[email protected]> |
cjxgm left a comment (vim/vim#21000) > I think the result you're after can be achieved this way: > > set nowrap > set foldmethod=expr > set foldminlines=0 > set foldexpr=getline(v:lnum)=~'^\\s'&&(getline(v:lnum-1)=~'^\\s'\|\|getline(v:lnum+1)=~'^\\s') > > First I set 'foldminlines' to 0 so that 'foldexpr' has full control of folding. Then I modify 'foldexpr' so it doesn't produce any single-line folds: an indented line is made foldable, but only when the preceeding or following line is also indented. The result is that indented lines are foldable but lone indented lines are not---regardless of wrapping. This indeed works, though a bit tedious and maybe complex logic-wise, esp. when the foldexpr does not just produce numbers but produces a mixture of `n`, `'>n'`, `'<n'` and all those sorts of results. Anyway, I did find a way to rewrite my foldexpr with the same idea. > I will say, at a first glance it is a little odd that 'foldminlines' pretends that wrap is on even when it's off, but I'm not familiar enough with folding to comment on this. The behavior being kind of a surprise is why I submit this as a bug report. -- Reply to this email directly or view it on GitHub: https://github.com/vim/vim/issues/21000#issuecomment-5307287183 You are receiving this because you are subscribed to this thread. Message ID: <vim/vim/issues/21000/[email protected]> -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/vim/vim/issues/21000/5307287183%40github.com.