Hard wrapping in vim without joining
- by Miles
Vim newbie here. How can I hard wrap plain text in vim (inserting actual linebreaks), respecting word boundaries, without joining existing lines?
For example, given this:
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
- Nulla cursus accumsan faucibus.
- Donec dapibus dignissim ullamcorper.
Integer
nec
malesuada
diam.
I'd like to get (with textwidth=30):
Lorem ipsum dolor sit amet,
consectetur adipiscing elit.
- Nulla cursus accumsan
faucibus.
- Donec dapibus dignissim
ullamcorper.
Integer
nec
malesuada
diam.
instead of this (which I can get with gggqG)
Lorem ipsum dolor sit amet,
consectetur adipiscing elit.
- Nulla cursus accumsan
faucibus.
- Donec dapibus dignissim
ullamcorper.
Integer nec malesuada diam.
Also, for bonus points: when I create a brand new buffer, I get different wrapping behavior (lines beginning with - aren't wrapped specially) than when I open a file ending in .txt. What controls this? I don't notice any difference in the output of :set filetype? or :filetype.