ReST mode: Indentation in ordered lists vs. unordered lists

21 views
Skip to first unread message

Friedrich Romstedt

unread,
May 14, 2021, 9:22:24 AM5/14/21
to vim...@googlegroups.com
Hi all,
Hi Marshall,

When starting an ordered list::

1. hello

with two spaces between the ``1.`` and the ``hello``, pressing Return
at the end of the line leads to an indentation by four spaces, s.t.
the cursor is located directly beneath the beginning of ``hello``.
Other amounts of space between the ``1.`` and the ``hello`` are
respected as well.

However, when writing unordered lists::

* hello

or::

- hello

or::

+ hello

with three spaces between the bullet marker and the word "hello",
pressing Return leaves the cursor indented with two spaces. This is
independent on the number of spaces between the marker and the text.

It is easy enough to indent manually when writing such paragraphs.
However, when reflowing paragraphs in an unordered list by ``gq`` in
"visual line" mode (``V``), it is a little tedious to reformat the
paragraph starting at its second line, after the first line is
complete.

Would it be possible to change vim's behaviour in this respect?

Best,
Friedrich

Bram Moolenaar

unread,
May 14, 2021, 10:58:18 AM5/14/21
to vim...@googlegroups.com, Friedrich Romstedt
You don't mention what option values you use, but you should be able to
make it work by:
include the "n" flag in 'formatoptions'
Adjust the 'formatlistpat' option, e.g. to use a list with "+":
set formatlistpat=^\\s*\\(\\d\\+[\\]:.)}\\t\ ]\\\\|+\\)\\s*


--
There is a fine line between courage and foolishness.
Unfortunately, it's not a fence.

/// Bram Moolenaar -- Br...@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 ///

Friedrich Romstedt

unread,
May 14, 2021, 12:41:19 PM5/14/21
to Bram Moolenaar, vim...@googlegroups.com
Hello Bram,
Before trying to tweak the 'formatlistpat' option (with the
double-backslashes contracted), I tried it out with the standard value
and ``:set fo+=n`` in a vanilla buffer (``$ vim``), however no
numbered lists are "recognised". I will do more research later. (The
'autoindent' option is set.)

So far, thanks for the hint.

BTW, shouldn't it be only one (two, in your case) backslashes prior to
the alternative '|'? It looks like if the '|' should be, in your
case, two more characters to the left?

How is implemented the default indentation for ordered lists in the
ReST mode (which works also with the "default" formatoptions='tcroql'
I found to be present); and could the present behaviour w.r.t.
unordered lists be changed still? Your proposition of using the 'n'
formatoption looks more like a workaround to me.

Friedrich

Bram Moolenaar

unread,
May 14, 2021, 4:00:33 PM5/14/21
to vim...@googlegroups.com, Friedrich Romstedt, marsha...@gmail.com
See ":help option-backslash" for an explanation. Unfurtunately this is
complicated. Another way is to use an assignment:
:let &formatlistpat = 'value'

> How is implemented the default indentation for ordered lists in the
> ReST mode (which works also with the "default" formatoptions='tcroql'
> I found to be present); and could the present behaviour w.r.t.
> unordered lists be changed still? Your proposition of using the 'n'
> formatoption looks more like a workaround to me.

I'll Cc the maintainer of the ReST indent file.

--
A cow comes flying over the battlements, lowing aggressively. The cow
lands on GALAHAD'S PAGE, squashing him completely.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

Marshall Ward

unread,
May 16, 2021, 1:58:35 PM5/16/21
to vim_dev
I agree that the indentation of these should not be fixed at 2 spaces,
and should be more aware of the preceding line.

There may be some overlap with a current PR which is attempting to
resolve the harder problem of n-digit list syntax highlighting (also
cross-posted to this mailing list), so it might be worthwhile to address both of these issues at the same time.
Reply all
Reply to author
Forward
0 new messages