I use a rather nifty automatic text formatting for Markdown:
(Seen https://asciidoc.org/userguide.html#X61)
augroup TXT | au!
autocmd FileType asciidoc,markdown
\ setlocal autoindent expandtab tabstop=8 softtabstop=2 shiftwidth=2
\ textwidth=70 wrap formatoptions=atqn
\ formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\\|^\\s*<\\d\\+>\\s\\+\\\\|^\\s*[a-zA-Z.]\\.\\s\\+\\\\|^\\s*[ivxIVX]\\+\\.\\s\\+
\ comments=s1:/*,ex:*/,://,b:#,:%,:XCOMM,fb:-,fb:*,fb:+,fb:.,fb:>
\ listchars=tab:»·,trail:·
\ list |
autocmd FileType asciidoc,markdown silent! %foldopen!
augroup END
This auto-indents lists and keeps my text blocks short by automatically inserting hard breaks or removing them where appropriate.
However this behaviour gets in my way when entering fenced code, as Vim tries to merge lines not separated by a paragraph together until textwidth is reached.
Can I disable auto formatting in fenced code altogether? How would comments=
look like to treat everything between
```
fenced code
```
as a comment Vim should not auto-format? See the absence of formatoptions=-c
above which I assume Vim would take to leave my comments alone.