Quantcast
Channel: vim command to restructure/force text to 80 columns - Stack Overflow
Viewing all articles
Browse latest Browse all 7

Answer by Ehtesh Choudhury for vim command to restructure/force text to 80 columns

$
0
0

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.


Viewing all articles
Browse latest Browse all 7

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>