When I'm in a markdown file creating a task list, I want it to insert a task list not a list item.


- [ ] **A task** - A task list <Enter>
- Inserted just a dash

Would like this:

- [ ] **A task** - A task list <Enter>
- [ ] Inserts a task list

I already setlocal fo+=n and looked into formatlistpat but I can't even seem to insert numbers let alone do what I want to even if I add to the default pattern ^\s*\d\+[\]:.)}\t ]\s*.

I know I can probably just hack it with a function or autocomand, just wondering if there's an option like indentexpr or formatlistpat that could help me with this. What is the option that does this behavior to automatically insert stuff?

  • 1
    :help fo-table suggests the o option is responsible for automatic insertion, maybe? But that's for comments; I would have though n with the right pattern would work, but perhaps it's too specific to numbers.
    – D. Ben Knoble
    Apr 2, 2021 at 21:20
  • @D.BenKnoble yea that's for comments, not sure if such a feature even exists. I guess I will just have to make it work with a function or something. I thought the indentexpr did that but turns out that's just for returning the indent levels. Not even sure what is causing that, I went into an account with a minimal vimrc and 2 plugins and it also does that.
    – ritchie
    Apr 2, 2021 at 23:10

1 Answer 1


I figured it out. If you have a markdown plugin, patch it or disable it. Some plugins will have autocommands that will override your settings regardless of what you put in your after/markdown.vim.

:help 'com'
:help format-comments

In your ftplugin/markdown.vim put this.

setlocal com=:\-\ [\ ]\ **,b:\-\ [\ ],b:>,b:*,b:+,b:-

Tested, works.

- This is a normal list.
- This is a normal list.
- [ ] This is a task.
- [ ] This is a task.
- [ ] **Bold** - Bold in a task.
- [ ] **Bold** - Bold in a task.

Improvements: Well, if you want to get really picky and don't feel like typing '** - ' after '- [ ] **' then you might want to look into:

  • [x] Ultisnips - A great plugin for Snippets.
  • [x] Funciton - Create your own vim function to handle this.
  • [x] Help - Read more into the help format-comments.

P.S I don't think stackoverflow allows for github task list items.

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.