Re: [vim/vim] long lines automatically become foldable even with set nowrap (Issue #21000)

Emilien Breton (Vim Github Repository) <[email protected]>
Newsgroups gmane.editors.vim.devel
Message-ID <vim/vim/issues/21000/[email protected]>
Bricktech2000 left a comment (vim/vim#21000)

I think the result you're after can be achieved this way:

```vim
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.

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.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/vim/vim/issues/21000#issuecomment-5303969308
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/5303969308%40github.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.