Wednesday, May 27, 2015

Re: reformatting comments

Hi Ben!

On Mi, 27 Mai 2015, Ben Fritz wrote:

> On Wednesday, May 27, 2015 at 10:06:11 AM UTC-5, Christian Brabandt wrote:
> > Hi,
> > Can someone explain this behaviour?
> >
> > vim -u NONE -N --cmd ':set comments=e:%% tw=20' -c 'call setline(1, "%%
> > ".repeat("foobar ", 10))' -c 'norm! Vgq'
> >
> > Output:
> > ,----
> > | %% foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar
> > `----
> > Note: not reformated to fit into the textwidth
> >
> > Expected Output:
> > ,----
> > | %% foobar foobar
> > | %% foobar foobar
> > | %% foobar foobar
> > | %% foobar foobar
> > | %% foobar foobar
> > `----
> > (Reformated to fit into textwidth, the comment leader might be left
> > away)
> >
>
> Why do you expect this behavior?

Well, this was a reduced example from a tex file, that I could not
reformat, because a comment started with %%. I expect even the endpart
of a comment to be reformatable according to the current &tw setting.

> You're specifying only the end part of a 3-part comment, making it an
> invalid entry. From :help format-comments:
>
> > A three-piece comment must always be given as start,middle,end, with
> > no other parts in between. An example of a three-piece comment is
> > sr:/*,mb:*,ex:*/

Well, have you tried it with a complete three-piece comment? Latex Files
are a good example:
(taken from $VIMRUNTIME/ftplugin/initex.vim)

vim -u NONE -N --cmd ':set comments=sO:%\ -,mO:%\ \ ,eO:%%,:% tw=20' -c
'call setline(1, "%% ".repeat("foobar ", 10))' -c 'norm! Vgq'

(still does not reformat).


Best,
Christian
--
Wer viel Geld hat, kann spekulieren; wer wenig Geld hat, darf nicht
spekulieren; wer kein Geld hat, muß spekulieren.
-- André Kostolany

--
--
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.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment