David - Musings of an SRE

Disable wordwrapping for easier markdown composing in vim

If you’re writting a really long prose in markdown, you probably have experienced the annoying thing that vim does when dealing with a long line; it creates linebreaks when your textwidth value is met.

This gets absolutely annoying especially since markdown reads linebreaks as linebreaks and displays it as such when rendered.

Fret not, a quick way is to set your autocmd in your .vimrc to disable said wrapping for markdown files or any file extension that you’d like.

# ~/.vimrc
autocmd BufNewFile,BufRead *.txt,*.md setlocal formatoptions=ant textwidth=0 wrapmargin=0 wrap linebreak nolist formatoptions=-t