Wednesday, June 6, 2012

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

On Mon, Jun 04, 2012 at 12:15:55PM -0700, Ben Fritz wrote:
> 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.

Thanks for your reply. I did get my patch working as I want... :^)

Anyone interested in my patch can review it here:

Subject: Patch: fo=q (comments) w/ n (num list) or 2 (2nd line) indent

http://groups.google.com/group/vim_dev/browse_thread/thread/72e109959b6794fc

If you click on "More options-->Show original", you can view the
message with a fixed space font, which I prefer...

Thanks!

- Tor

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