I'm currently writing a lot of plain text (and LaTeX with minimal formatting in paragraphs), and it would be nice if I could set up vim to keep each sentence (for simplicity, text terminated by a '. ', '! ', or '? '; that is a terminating punctuation followed by a space so as to avoid breaking on decimal numbers) on its own line so the VCS diffs will be more useful.
Minimally, I'd like gq
to format text from:
He lay flat on the brown, pine-needled floor of the forest, his chin on his
folded arms, and high overhead the wind blew in the tops of the pine trees.
The mountainside sloped gently where he lay; but below it was steep and he
could see the dark of the oiled road winding through the pass. There was a
stream alongside the road and far down the pass he saw a mill beside the
stream and the falling water of the dam, white in the summer sunlight.
To:
He lay flat on the brown, pine-needled floor of the forest, his chin on his folded arms, and high overhead the wind blew in the tops of the pine trees.
The mountainside sloped gently where he lay; but below it was steep and he could see the dark of the oiled road winding through the pass.
There was a stream alongside the road and far down the pass he saw a mill beside the stream and the falling water of the dam, white in the summer sunlight.
But it would be nice if vim would also perform this formatting as I type (like it does with textwidth reflow). Is this possible?
My current solution is to join a paragraph with J
, then run :'<,'>s/\. /.\r/g
which is pretty good as there are few exclamation and question marks, but it would be much better if I could make gq slightly smarter.