Formatting Markdown with code blocks in Vim
I like to keep
textwidth=80 when working on markdown documents so things are
easier to read. However, documents with codeblocks often need to be longer.
Using the built in format program results in vim constantly formatting your code
in ways you didn't intend.
The way to solve this problem is to set a different formatter for markdown code. I do this with:
autocmd FileType markdown,vimwiki setlocal formatprg=fmtmd textwidth=80
fmtmd is a small python script that doesn't touch things in multiline code
blocks. I have it set up as an executable and available on my path.