Tuesday, October 18, 2022

Re: Comment auto formatting joins non-comment lines

> I like the autoformatting of comments when I'm writing them, however it's
> unusable because subsequent non-comment lines are always joined with the
> comment block.
>
> Use of fo+=w helps a little bit, but if I accidentally leave Insert mode
> when there is a trailing space on the last line of my comment, it will join
> it with the next line regardless of whether the next line is a comment or
> not. This is really annoying and feels like incorrect behavior. It seems to
> me that autoformatting should never change or join a non-comment line into
> a comment line.
>
> For example, I might have code like the following:
>
> // FooBar does things.
> func FooBar() {
> return
> }
>
> If my formatoptions are
> formatoptions=crqwn1ja
>
> Then when I go to edit the comment, if I happen to leave a space at the end
> accidentally, then it is autoformatted into this:
>
> // FooBar does things. func FooBar() {
> return
> }
>
> If w isn't set then the space doesn't matter and it will always get
> formatted into that immediately.
>
> Is this correct behavior? Is there a way to get vim to auto format comments
> but never join a non-comment line? Or should I just resign and not use the
> fo+=a option for code?

This looks like a bug, since you have the "c" flag, which together with
"a" should mean only comments are auto-formatted.

--
<Beeth> Girls are like internet domain names,
the ones I like are already taken.
<honx> Well, you can stil get one from a strange country :-P

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20221018121154.C74FD1C0EE2%40moolenaar.net.

No comments: