Reputation: 75575
This question is related to this previous question, but I have reached a bit of a stumbling block in trying to get the same behavior with numbered lists.
As a reference, here is what the configuration looks like in the previous question:
set formatoptions=tcq
set comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-
set autoindent
I read the output of :help comments
and jumped to also read format-comments
. Based on that page, it seemed that I needed to add some expression with the flag fb
to represent numbered lists. I tried the following.
set comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-,fb:\d\+.
It did not throw any errors, but it also did not have any noticeable effect.
In particular, the sample text looks the same before and after gq
.
1. This is a numbered list item that has been wrapped. The second line is not
indented as desired.
The desired output looks like this:
1. This is a numbered list item that has been wrapped. The second line is not
indented as desired.
Upvotes: 1
Views: 446
Reputation: 5122
If you read :help 'formatoptions'
and follow the link to :help fo-table
, then you will find the n
option that does exactly what you want:
:set fo+=n
The 'comments'
option does exactly what the docs say, and they do not mention that any part of it can be a general pattern, so I am not surprised that adding \d
did not help.
@kev's answer mentions the 'formatlistpat'
option, but the setting he recommends is already the default.
Upvotes: 5
Reputation: 161814
Take a look at :help 'formatlistpat'
:
:set tw=80
:set flp=^\\s*\\d\\+[\\]:.)}\\t\ ]\\s*
Upvotes: 2