4 ms·
The nice thing about using `=` instead of `gq` is that you can “set equalprg” to something smarter than the internal Vim formatter, such as `fmt` or `par`:
by wyoung2 8y ago
The nice thing about using `=` instead of `gq` is that you can “set equalprg” to something smarter than the internal Vim formatter, such as `fmt` or `par`:
https://www.gnu.org/software/coreutils/manual/coreutils.html#fmt-invocation
http://www.nicemice.net/par/
These formatters will do nice things like choose line breaks intelligently to reduce the raggedness of the right edge. I just tested `gqip` on a paragraph in a Markdown document here that was formatted with `fmt`: the `fmt` output put breaks in such that all but the last line was within one character of equal, whereas `gqip` had line lengths varying as much as 5 characters on a 72 character line length.
A quicker alternative to Shift-V, arrows, then `=` to reformat a paragraph with `fmt` is this:
:map <F2> !}fmt -w72<CR>
That works anywhere inside the paragraph like with your `gqip`, but it uses the smarter `fmt` paragraph formatter.
Select your keystroke to taste. I chose F2 so long ago that I forget why that was a good idea at the time.