Reputation:
I'm writing Markdown with Vim. Let's say my file contains this:
La Cigale, ayant chanté tout l'été,
Se trouva fort dépourvue
Quand la bise fut venue.
_Jean de la Fontaine_
I know that if I want to add line breaks I have to add two spaces at the end of said line (this is what I did here). But when reformatted by Vim this is transformed as:
La Cigale, ayant chanté tout l'été, Se trouva fort dépourvue Quand la bise
fut venue.
_Jean de la Fontaine_
My problem is that when working with text I include a
in my formatoptions
and I'm accidentally reformatting paragraphs and losing all my lines breaks a lot of time. I know that when "compiled" this will still produce the output that I want. But I'd like my file to look as readable as possible. Is there a way to do so? Thanks!
Upvotes: 2
Views: 1447
Reputation:
I found it! Adding w
to my formatoptions
fixed it.
w Trailing white space indicates a paragraph continues in the next line.
A line that ends in a non-white character ends a paragraph.
Upvotes: 0
Reputation: 17353
You can override formatoptions
for Markdown files. Create a ~/.vim/ftplugin/mkd.vim
and put this in it:
setlocal formatoptions-=a
You can put whatever commands you want in this file, and they'll get executed when you edit a Markdown file. Using setlocal
makes the option affect only the current buffer, and putting it in a ftplugin
file makes it apply whenever the matching filetype is encountered.
Upvotes: 3