Monday, June 4, 2012

Re: formatoptions q (comments) and 2 (2nd line) bad together...?

On Friday, June 1, 2012 1:25:03 PM UTC-5, Tor Perkins wrote:
> Greetings all,
>
> Given these settings:
>
> :set tw=20
> :set comments=b:#
> :set formatoptions=tcq2
> :set smartindent
>
> ... and given this text:
>
> NOTE: blah blah
> blah blah
>
> # NOTE: blah blah
> # blah blah
>
> If I do gq{motion} on the top paragraph, formatting is unchanged (as
> expected), however, gq{motion} (or gwap) on the bottom paragraph
> results in this new formatting:
>
> # NOTE: blah blah
> # blah blah
>
> So, even though I have both the 2 and q formatoptions, the second
> line's indentation seems to be ignored when within a comment block.
> I would prefer if it could be honored in this case as well. Is that
> possible...?
>
> Interestingly, the t and c formatoptions (for auto-wrap) are working
> properly with formatoptions+=2 in both paragraphs...
>

I ran into this problem some time ago:
https://groups.google.com/d/topic/vim_use/hjoM4IdPgMY/discussion

I gave up on that line of attack for the problem and eventually wrote my own formatexpr. It doesn't correctly reformat a short first line to include text from the second line but it works fairly well aside from that. I don't remember if I ever tried the plugin recommended in that thread ( http://www.vim.org/scripts/script.php?script_id=1939 ), you might want to look into that, unless you can quickly get your patch working as you want.

--
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