4

How to make vim respect the enumerated list indentation also on consecutive, not only on the second line? I.e. so that pressing gq on:

1. A long line reaching near &tw.
following text on the second line.
the "consecutive" line.

would yield:

1. A long line reaching near &tw.
   following text on the second
   line. the "consecutive" line.

and not like it is by default, currently in my vim:

1. A long line reaching near &tw.
   following text on the second
line. the "consecutive" line.

?

1 Answer 1

1

You just need to do this:

:set fo+=n

That'll add a flag to "recognize numbered lists" to 'formatoptions' ('fo' for short).

Note the details/limitations:

This actually uses the 'formatlistpat' option, thus any kind of list can be used. The indent of the text after the number is used for the next line. The default is to find a number, optionally followed by '.', ':', ')', ']' or '}'. Note that 'autoindent' must be set too. Doesn't work well together with "2".

Excerpted from fo-table which has the complete list of 'formatoptions' flags.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.