On Mon, 3 Mar 2003, Cory Petkovsek wrote:
>Is there a simple command line tool (?roff) to justify text with preferably
>left and right justification or auto line-wrapping and unwrapping?
>
>Recall a discussion when Dexter left the list about his last email that was
>fully left and right justified without additional spaces. Ralph said, "How
>quickly we forget the wonders of troff."
>
>Here is the scenario: Vim has a nice feature that will format text wether
>it is too long for a line or nor long enough to fill it. By typing gqq I
>can format a line or with a few other commands a whole block of text. I've
>switched to nvi a less feature enhanced clone of vi. Why use one with less
>features? To restrict myself and thus to learn a more universal vi command
>set. In nvi when I type, it auto line-wraps. However if I go back and edit
>that line, I might end up with a less than full line. I then manually have
>to adjust each line in the paragraph. Is there a standard vi key command to
>do this automatically? Or what I'd like is to just type "10_!troff -format"
>and have it automatically justify the text.
First of all, troff is NOT what you want to use. Troff will output
phototypesetter instructions, not plain text. You might, however, be able
to use troff's little brother nroff, if you don't mind lots of extra blank
lines at the end of your text.
I usually use "fmt" for these purposes. For example, to reflow a paragraph
in vi,
!}fmt
With no arguments, GNU fmt (the version usually used on Linux) outputs
lines no longer than 75 characters. "Classic" flavors of fmt usually
output lines no longer than 72 characters. You can specify a different
maximum width with the "-w" argument, for example,
!}fmt -w78
to reformat the current paragraph in vi in 78-character-max lines. (You can
omit the "w" in the argument, and just say "fmt -78"...in fact, this may be
required on some UNIX versions.)
One thing fmt won't do for you is justify both margins. But that's not a
great loss...fixed-width text usually doesn't look very good when both the
left and right margins are justified, unless the word lengths happen to be
just right to make the text justify naturally.
If you absolutely must have text justified on both margins, use
nroff--most (but not all!) versions will put in extra blank spaces to
justify the right margin.
- Neil Parker
_______________________________________________
Eug-LUG mailing list
[EMAIL PROTECTED]
http://mailman.efn.org/cgi-bin/listinfo/eug-lug