BUG: formatoptions+=t makes comments wrap (incorrectly) when they shouldn't

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

BUG: formatoptions+=t makes comments wrap (incorrectly) when they shouldn't

Peter Hodge-2
Hello,

When I have formatoptions=t, it makes comment lines wrap when they shouldn't,
and it also ignores whatever comment leader is defined in 'comments'.  To
reproduce:


  :set formatoptions=roc
  :set comments=b:%
  :set textwidth=30

  % type these lines of text
  % as one line, and notice
  % how Vim automatically
  % wraps the lines and adds
  % '%' at the start of each
  % line.

Now remove 'c' from formatoptions and add 't'.
  :set formatoptions-=c
  :set formatoptions+=t
From the help pages (:help fo-table)
        t   Auto-wrap text using textwidth (does not apply to comments)
        c   Auto-wrap comments using textwidth, inserting the current comment
            leader automatically.
With 'formatoptions' now set to 'rot', Vim should wrap normal text, but not
comments.

  % but when you type this
  next set of comments, Vim
  will wrap them (when it
  shouldn't, because they are
  comments), and it will also
  miss out the comment leader.

I hope it's clear what's going on here.  I'm running Vim 7 with patches 1-101.

regards,
Peter


               
____________________________________________________
Do you Yahoo!?
Cars: Buy and sell, news, reviews, videos and more
http://yahoo.drive.com.au/
Reply | Threaded
Open this post in threaded view
|

Re: BUG: formatoptions+=t makes comments wrap (incorrectly) when they shouldn't

Bram Moolenaar

Peter Hodge wrote:

> When I have formatoptions=t, it makes comment lines wrap when they
> shouldn't, and it also ignores whatever comment leader is defined in
> 'comments'.  To reproduce:
>
>
>   :set formatoptions=roc
>   :set comments=b:%
>   :set textwidth=30
>
>   % type these lines of text
>   % as one line, and notice
>   % how Vim automatically
>   % wraps the lines and adds
>   % '%' at the start of each
>   % line.
>
> Now remove 'c' from formatoptions and add 't'.
>   :set formatoptions-=c
>   :set formatoptions+=t
> From the help pages (:help fo-table)
>         t   Auto-wrap text using textwidth (does not apply to comments)
>         c   Auto-wrap comments using textwidth, inserting the current comment
>             leader automatically.
> With 'formatoptions' now set to 'rot', Vim should wrap normal text, but not
> comments.
>
>   % but when you type this
>   next set of comments, Vim
>   will wrap them (when it
>   shouldn't, because they are
>   comments), and it will also
>   miss out the comment leader.
>
> I hope it's clear what's going on here.  I'm running Vim 7 with
> patches 1-101.

When you remove "c" from 'formatoptions' Vim doesn't recognize comments,
thus everything is formatted as normal text.

I don't think there currently is a value for 'formatoptions' to only
format text that isn't comments.  Mostly because comments is text that
you normally want to format.

--
hundred-and-one symptoms of being an internet addict:
74. Your most erotic dreams are about cybersex

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
Reply | Threaded
Open this post in threaded view
|

Re: BUG: formatoptions+=t makes comments wrap (incorrectly) when they shouldn't

Peter Hodge-2

--- Bram Moolenaar <[hidden email]> wrote:

>
> Peter Hodge wrote:
>
> > When I have formatoptions=t, it makes comment lines wrap when they
> > shouldn't, and it also ignores whatever comment leader is defined in
> > 'comments'.  To reproduce:
> >
> >
> >   :set formatoptions=roc
> >   :set comments=b:%
> >   :set textwidth=30
> >
> >   % type these lines of text
> >   % as one line, and notice
> >   % how Vim automatically
> >   % wraps the lines and adds
> >   % '%' at the start of each
> >   % line.
> >
> > Now remove 'c' from formatoptions and add 't'.
> >   :set formatoptions-=c
> >   :set formatoptions+=t
> > From the help pages (:help fo-table)
> >         t   Auto-wrap text using textwidth (does not apply to comments)
> >         c   Auto-wrap comments using textwidth, inserting the current
> comment
> >             leader automatically.
> > With 'formatoptions' now set to 'rot', Vim should wrap normal text, but not
> > comments.
> >
> >   % but when you type this
> >   next set of comments, Vim
> >   will wrap them (when it
> >   shouldn't, because they are
> >   comments), and it will also
> >   miss out the comment leader.
> >
> > I hope it's clear what's going on here.  I'm running Vim 7 with
> > patches 1-101.
>
> When you remove "c" from 'formatoptions' Vim doesn't recognize comments,
> thus everything is formatted as normal text.
>
> I don't think there currently is a value for 'formatoptions' to only
> format text that isn't comments.  Mostly because comments is text that
> you normally want to format.

OK, I understand now.  Perhaps the fo-table docs should read:

  t      Auto-wrap all text using textwidth.  Comment leader is not inserted
         automatically unless 'c' is present also.

Otherwise, it appears as though 't' should wrap everything except comments.
"... (does not apply to comments)".

regards,
Peter



               
____________________________________________________
On Yahoo!7
Men's Health Radio: Chill out or work out, or just tune in http://au.launch.yahoo.com/mens-health-radio/index.html