Justify Text

320 views
Skip to first unread message

Cerebus

unread,
Feb 26, 2013, 6:29:31 PM2/26/13
to Bbedit List

Sometimes, though not very often, I want to justify plain text. When I want to do this, I use vim since as far as I know there isn't a way to do it in BBedit.

But when I was doing it earlier today I thought, "Now wait a minute, there must be."

But "Justify" only appears on one page in the manual, and it's talking about line numbers.

(Justify is not built in to vim, but there's a macro for it).

I found a Justify Text.pl that does this, but it processes the entire file, and I want to either process a selection of the current paragraph, not the entire file.

==cut
#!/usr/bin/perl

# Make sure Text::Autoformat is installed; if in doubt, do this on the
# command line:
# cpan Text::Autoformat

use strict;
use Text::Autoformat qw(autoformat break_TeX);

# Read in all data.
# TODO: This could be a problem for large input data. So what we really
# should do is to read everything until we find an empty line. Then
# invoke autoformat on what we read so far, and output its result. Then
# go on.
my $rawtext;
while (<>) {
$rawtext .= $_;
}

# Format it and output it again
print autoformat $rawtext, { justify => 'full', all=>1, right => 70 };
==cut


--
'Why?' he [Rincewind] said. The world is going to end. 'What, again?'

John Delacour

unread,
Feb 26, 2013, 7:54:05 PM2/26/13
to bbe...@googlegroups.com
On 26/02/2013 23:29, Cerebus wrote:
>
> Sometimes, though not very often, I want to justify plain text. When I want to do this, I use vim since as far as I know there isn't a way to do it in BBedit.

BBEdit is a text editor and to talk of "justifying plain text" is a
contradiction in terms. There is no way to do true justification in any
plain text editor. If you use a monospaced font then sure you can add
spaces arbitrarily to space things out, but that is not proper
justification, which relies on kerning and other rules not available in
any text editor.

JD


LuKreme

unread,
Feb 26, 2013, 8:25:22 PM2/26/13
to bbe...@googlegroups.com
Yes, but I thought I was quite clear. I can do this in vim
and end up with a block of text that has spaces added in
to space out the letters and yield a 'justified' looking
block of text that is still monospaced, but does not have
a ragged right margin.

Just exactly like in the above paragraph.


--
I have as much authority as the Pope, I just don't have as many people
who believe it.


Gregory Shenaut

unread,
Feb 26, 2013, 9:05:44 PM2/26/13
to bbe...@googlegroups.com
Can't you just filter the text block through “par j1” ?

Greg
> --
> --
> You received this message because you are subscribed to the
> "BBEdit Talk" discussion group on Google Groups.
> To post to this group, send email to bbe...@googlegroups.com
> To unsubscribe from this group, send email to
> bbedit+un...@googlegroups.com
> For more options, visit this group at
> <http://groups.google.com/group/bbedit?hl=en>
> If you have a feature request or would like to report a problem,
> please email "sup...@barebones.com" rather than posting to the group.
> Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
>
> ---
> You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

David Kendal

unread,
Feb 26, 2013, 8:29:04 PM2/26/13
to bbe...@googlegroups.com
On 27 Feb 2013, at 01:25, LuKreme <kre...@kreme.com> wrote:

> Yes, but I thought I was quite clear. I can do this in vim
> and end up with a block of text that has spaces added in
> to space out the letters and yield a 'justified' looking
> block of text that is still monospaced, but does not have
> a ragged right margin.

Indeed, this is the default formatting for man pages. Type
'man sh' into a terminal window to see it in action.

— dpk.

Lawrence San

unread,
Feb 27, 2013, 10:04:19 PM2/27/13
to bbe...@googlegroups.com

Indeed, this is the default formatting for man pages. Type
'man sh' into a terminal window to see it in action.

That's true, and I've wondered _why_ Terminal does that. It seems like it just makes the man pages slightly harder to read. For that matter, I'm curious why anybody would want to justify text in a plain-text editor, or even in a crummy word processor. A real publishing program has sophisticated tracking, kerning, and hyphenation routines (usually called "H&J") that all work together to even out the text flow.

Andrew Brown

unread,
Feb 28, 2013, 2:09:56 AM2/28/13
to bbe...@googlegroups.com
On 28 févr. 2013, at 04:04, Lawrence San <lawre...@gmail.com> wrote:

> A real publishing program has sophisticated tracking, kerning, and hyphenation routines (usually called "H&J") that all work together to even out the text flow.

Tracking and kerning should be left out of this this discussion, since they should play no role in H&J -- justification should involve only adjustments to the spaces between words and, of course, the choice of suitable break points. Tracking increases or decreases the space between a range of characters, and should be used exclusively in headers and the like. Kerning adjusts the spaces between characters that sit awkwardly together, and once fixed for a particular font should never be adjusted for H&J.

AB

Lawrence San

unread,
Feb 28, 2013, 12:41:47 PM2/28/13
to bbe...@googlegroups.com
Tracking and kerning should be left out of this this discussion, since they should play no role in H&J

You're right, for the most part they should play no role. It's been so long since I've worked with justified type for print that I didn't remember clearly all the preferences and tradeoffs I used to experiment with. On the other hand, I seem to recall some printed newspapers with narrow columns using obvious tracking as part of their justification routines, resulting in rather ugly type.

I'm still curious why Terminal uses justified type for man pages, and why somebody would want justified type in a plain-text file.
 

Fritz Anderson

unread,
Feb 28, 2013, 1:09:11 PM2/28/13
to bbe...@googlegroups.com
On 28 Feb 2013, at 11:41 AM, Lawrence San <lawre...@gmail.com> wrote:

> I'm still curious why Terminal uses justified type for man pages, and why somebody would want justified type in a plain-text file.

It's not Terminal, it's the man command, which has worked that way since the '70s. The text-filtering tool roff/nroff/groff, that takes man-page specs and converts them to formats like PostScript and plain text, tries to put out as consistent a presentation as it can. The PostScript output is justified, so the plain-text output is, too.

It doesn't matter why someone would want justified plain-text blocks. People do, and they have reasons that are good enough for them, even if we can't guess them. There are readability tradeoffs, but those are tradeoffs, and different people make different choices.

I'm not saying BBEdit has to support it, but it's not an unreasonable request. The demand has gone down, but even a little demand is worth considering.

— F

--
Fritz Anderson
Xcode 4 Unleashed: 4.5 supplement for free!
http://www.informit.com/store/xcode-4-unleashed-9780672333279

William E Reveal

unread,
Feb 28, 2013, 1:11:19 PM2/28/13
to bbe...@googlegroups.com
It isn't Terminal that is justifying the text. The man app is doing it. Furthermore, normally man is displaying the text using a mono type so that it is easy to justify using spaces after a period. Why they develop man to do so is a matter of their aesthetics, probably goes back a long time. 

Bill

John Delacour

unread,
Feb 28, 2013, 6:27:23 PM2/28/13
to bbe...@googlegroups.com
On 28/02/2013 18:09, Fritz Anderson wrote:

> I'm not saying BBEdit has to support it, but it's not an unreasonable
> request. The demand has gone down, but even a little demand is worth
> considering. — F
It is very simple to write a Perl text filter to do what you want using
Text::Format

<http://search.cpan.org/~shlomif/Text-Format-0.58/lib/Text/Format.pm>

A text filter acts on the whole document, or on the selection if it exists.

There is no need for BBEdit to clutter itself up with things that can be
easily done with text filters, for which the user interface is excellent.

JD

LuKreme

unread,
Mar 1, 2013, 9:28:42 PM3/1/13
to bbe...@googlegroups.com
I wasn't suggesting that BBEDit add this feature. I even said in the original post that I'd found a BBEDit script that was supposed to do it, but it only worked on the entire file.

--
"He has never been known to use a word that might send a reader to the
dictionary." - William Faulkner (about Ernest Hemingway).


Reply all
Reply to author
Forward
0 new messages