Wednesday, October 5, 2011

Re: How to conceal entire line including newline?

Hi AK!

On Mi, 05 Okt 2011, AK wrote:

> On 10/05/2011 03:36 PM, Christian Brabandt wrote:
> >Hi AK!
> >
> >On Mi, 05 Okt 2011, AK wrote:
> >
> >>On 10/05/2011 02:41 PM, Christian Brabandt wrote:
> >>>On Mi, 05 Okt 2011, AK wrote:
> >>>>Hi, I want to have an overview of code without comments or
> >>>>docstrings, with their lines completely omitted when in
> >>>>conceal mode, without showing them as blank lines.
> >>>>
> >>>>How can I do that?
> >>>
> >>>You can't. Use folding to hide them away.
> >>>
> >>Wow, why is conceal so bizarrely hindered? Even before
> >>conceal feature was created, I've often thought that it
> >>would be extremely useful to temporarily conceal some
> >>types of lines.
> >
> >Well you can hide away lines, but I think you won't be able to
> >completely hide away the new line character. This makes sense, as for
> >this folding can be used.
>
>
> Well, here's an example:
>
> # comment
> code
> # comment
> # second line
> code
> # comment
> code
>
> I want to have:
>
> code
> code
> code
>
> Folding cannot do that because it does not conceal, it only folds.

Close enough:
:setl foldenable foldmethod=expr foldminlines=0
foldexpr=getline(v:lnum)=~'^#'?1:0 foldtext=v:folddashes foldlevel=0
fillchars-=fold:-

which makes it:
-
code
-
code
-
code


I was just going to suggest trying the NrrwRgn Plugin, which allows to
Narrow several non-continous regions like that. But the result of
:v/^#/NRP
:NRMulti
looks like this:
# Start NrrwRgn1
code1
# End NrrwRgn1

# Start NrrwRgn2
code2
# End NrrwRgn2

# Start NrrwRgn3
code3
# End NrrwRgn3

Which doesn't really help you either. (Those start and stop markers are
needed by NrrwRgn to let the plugin later associate each part to where
it belongs in the original buffer.

regards,
Christian

--
You received this message from the "vim_use" 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

No comments:

Post a Comment