Friday, June 12, 2015

Re: Formatting of lists and paragraphs containing numbers with fo+=n

On Friday, June 12, 2015 at 10:17:09 AM UTC-5, Marcin Szewczyk wrote:
> Hi,
>
> I would like vim to wrap text paragraphs automatically and indent list
> items as well. Currently I have formatoptions (fo) set to croqlwa1. In
> this context only "awn" flags are relevant.
>
> The problem is that with the "n" flag it is impossible to properly
> format a paragraph if a line within the paragraph begins with a number
> due to line width and wrapping. Vim then treats the next line as a part
> of a numbered list's item. It seems that when indenting list items vim
> ignores hints like trailing spaces at the end of the line before the
> line starting with a number. I thought that the "w" flag would enforce
> that.
>
> An example below. Explicit <SP>. A story mentioning some events during
> some years:
>
> Blah foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar
> 2013. bar foo bar foo bar foo bar. Foo bar foo bar foo bar foo bar<SP>
> foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar.
> Blah foo bar foo bar foo bar foo. Foo bar foo bar foo bar foo bar<SP>
> 2014. bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar<SP>
> bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar<SP>
> 2015. foo bar foo bar foo bar foo bar foo bar foo bar foo bar<SP>
> bar foo bar foo bar foo bar foo bar foo bar foo bar foo.
> 1. foo bar foo bar foo bar foo bar foo bar foo bar foo<SP>
> foo bar foo bar foo bar foo bar foo bar foo bar foo bar
> 2. foo bar foo bar foo bar foo bar foo bar foo bar foo<SP>
> foo bar foo bar foo bar foo bar foo bar foo bar foo bar
>
> While indents one line after items 1. and 2. are beneficial, indents
> added by vim one line after numbers describing hypothetical years are
> messing up the text.
>
> It happens automatically when the "a" flag is enabled or after pressing
> gqap.
>
> I have found a similar report from the past:
> https://groups.google.com/forum/#!searchin/vim_use/formatoptions$20indent$20number/vim_use/6Hv0e0FRJyU/piKRUB_j7gwJ
>
> Is this a bug or am I doing something wrong? Or maybe my problem could
> transform into a feature request?
>

Is this your stackoverflow post? http://stackoverflow.com/q/30783653/1390430

I understand your frustration; I've suffered the same problem in the past. But what I commented on stackoverflow is true: Vim does not know that you do not intend 2013 and 2014 to be a list. I see that you consider each list item to be its own paragraph (indicated by your use of trailing space) however not everyone sees it that way, and may include a list within a larger paragraph.

You may be able to piece together something using the 'formatexpr' option; I'm not sure how hard this will be.

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