This is so simple, I can't be bothered describing it. It's available from here.
In its current version, it does no checking
whatsoever for sanity. It doesn't allow for differnt widths than 80
characters per line, and it expects to be called with a single parameter,
and that that is the name of an existing text file.
I wrote it to sort out some HTML which
was generated by AbiWord, which
wasn't laid out nicely enough for me to use my favourite editor - vi - so I
wrote this to sort out its layout.
By the time you've downloaded this page, you could have gotten the source, and seen all of this for yourself.
I'm working on this, and wrap2 is much more capable.
It can pipe through stdin, and can cope with different lengths.
I am aware that this demo, by nature of its width, really screws up the layout of this website on
many browsers; I'm sorry
if that's a big thing for you, but all it means is that your browser
is non-compliant, or that you don't have a screen
resolution capable of 174 characters per line.
Not that I know anyone who does. Anyway, this is a C thing, not a web thing.
Shut up. Go away.
There's only one way to demo this on the web, and that's if you *can* display 174 cpl. If you
do have such a
big screen, and it still looks wrong, then fix your browser.
That's the excuses over, here's the example:
$ cat test.txt
hello this is a test file. It has some quite long lines, such as this one. Other lines, however, are much shorter than this. Whilst the first line is only just about to end, this is the second and much shorter. The third line, however, the good third line, that steady piece de resistance, is much longer than either of the other two. This is that self-same line, and look how long it is! Incredible. How could a line really be that long? That's all...$ wrap test.txt
hello this is a test file. It has some quite long lines, such as this one. Other lines, however, are much shorter than this. Whilst the first line is only just about to end, this is the second and much shorter. The third line, however, the good third line, that steady piece de resistance, is much longer than either of the other two. This is that self-same line, and look how long it is! Incredible. How could a line really be that long? That's all...$ cat test.txt | wrap -c 40
hello this is a test file. It has some quite long lines, such as this one. Other lines, however, are much shorter than this. Whilst the first line is only just about to end, this is the second and much shorter. The third line, however, the good third line, that steady piece de resistance, is much longer than either of the other two. This is that self-same line, and look how long it is! Incredible. How could a line really be that long? That's all...$
more
, head
and cut
in its usage.