For markdown files and the like, I have formatoptions set to tln and I am using a simplified version of formatlistpat that looks for digits and a * character. The indenting on a list works fine, the way I expect it to.

But, when I have a paragraph with numbers in it, where the auto-wrap causes the line to start with a numeric, it is acting like that line is a numbered list and indents the following line.


When you are writing code in Python
3.12, you need to ensure that you
   are using the latest version.

This drives me crazy enough that I have a function to quickly turn formatting on and off. Is there a better way to detect what is and isn't a list? Some way to say if the list section doesn't have a blank leading line it isn't a list? A way of invoking Q} two different ways, with and without list formatting?

Any tips / configuration help would be greatly appreciated.

  • I don't understand the Q} thing. Did you mean gq}?
    – Friedrich
    Commented May 22 at 16:07
  • Maybe could you share your formatlistpat and a small text just to verify that the solution proposed solves your problem. Commented May 22 at 16:53
  • Sorry, yes gq}, I have a nnoremap on Q which I've had for so long I forget that everyone else doesn't. Not sure where I picked that up Current settings that may be relevant: autoindent textwidth=78 formatoptions=tcql filetype=ghmarkdown formatlistpat=^\s*[0-9*]\+[\]:.)}\t ]\s* Commented May 22 at 17:00

1 Answer 1


I would suggest:

set autoindent
set indentexpr=

I suspect that indentexpr is automatically set to GetMarkdownIndent() that add the indentation you don't want.

The pattern I have used is:

set formatlistpat=^\\s*\\(\\d\\+[.)]\\\|\\*\\)\\s 


let &formatlistpat='^\s*\(\d\+[.)]|\*\)\s'

This to accept:

  * bullet1
  * bullet2


  1. bullet1
  2. bullet2

But not:

  3.12, foo
  3.1 bar

Remark: tested with:

set formatoptions=tln
set autoindent
set indentexpr=
set textwidth=80
  • 1
    Thanks @vivian-de-smedt it looks like it comes down to the formatlistpat, if I'm reading it correctly yours requires a numeric list to have a delimiter (period, bracket, etc) whereas mine allows blank. This means any number for me at the start of a line is getting interpreted as a list, whereas yours requires the number and the delimiter. Thanks for this, you've made my day! Commented May 22 at 17:17
  • Thanks for the feedback :-) I'm happy your problem is solved. Welcome to Vim! Commented May 22 at 18:06

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.