When I type 1. blah blah blah Vim recognizes the 1. prefix and it indents the rest of the paragraph tidy.

I would like to configure Vim to do the same thing with #. literal prefix, since ReST files autonumbers the paragraphs when started with #..

In this SO answer I got suggested this:

let &formatlistpat = '^\s*\%(\d\+\|#\)[\]:.)}\t ]\s*'

I added this to my .vimrc:

autocmd BufRead,BufNewFile *.rst let &formatlistpat = '^\s*\%(\d\+\|#\)[\]:.)}\t ]\s*'

It doesn't work. In fact, I modified the regexp and Vim seems to ignore anything I put there.

1 Answer 1


:help 'formatlistpat' says:

A pattern that is used to recognize a list header. This is used for the "n" flag in 'formatoptions'.

And :help 'formatoptions' says:

Vim default: "tcq"

:help fo-table describes the meaning of the n flag:

n        When formatting text, recognize numbered lists. This actually uses the 'formatlistpat' option, thus any kind of list can be used.
[..rest snipped..]

So I suspect it's probably a matter of just adding this flag to formatoptions. To add the flag, use:

set formatoptions+=n
  • In fact this actually work. THANKS!. But I wonder if the "default" behaviour can be modified without doing this. That is, VIM without "n" in formatoptions already recognize some numbered list formats. Is that hardcoded in the code?
    – jcea
    Commented Apr 28, 2015 at 22:39
  • @jcea It doesn't work with me when I test it with 1. ... Perhaps this is something in your specific filetype? Commented Apr 28, 2015 at 23:44

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.