If you're looking for a non-Vim way, there's always the UNIX commands fmt and par.
Notes:
- I can't comment on Unicode, it may or may not behave differently.
- @nelstrom has already mentioned using
par
in his webcast.
Here's how we would use both for your example.
$ echo -e 'long line is long!\nshort'> 3033423.txt$ cat 3033423.txtlong line is long!short$ fmt -w 13 3033423.txtlong line islong! short$ par 13gr 3033423.txtlong line islong! short
To use from inside Vim:
:%! fmt -w 13:%! par 13gr
You can also set :formatprg
to par or fmt and override gq
. For more info, call :help formatprg
inside Vim.