Break a line at a word division <= 80 char.

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
User avatar
tcebob
Posts: 80
Joined: Fri Mar 28, 2003 1:20 am

Break a line at a word division <= 80 char.

Post by tcebob »

. . . Thus simulating word wrap. Any guidance appreciated.

tcebob
ben_josephs
Posts: 2459
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Does this not do what you want?

In
Configure | Preferences | Document Classes | <Class>
or
View | Document Properties | Preferences
select
[X] Word wraplong lines
and
Word break at column number: 80
.
User avatar
tcebob
Posts: 80
Joined: Fri Mar 28, 2003 1:20 am

Post by tcebob »

Thanks, but no. I thought posting in the RE forum would imply that I want to develop an RE to edit documents so that every line is no longer than 80 characters long, but breaks at the beginning of a word. Sort of like:

begin of line
find 80th character
back up to beginning of word
insert \n

tcebob
ben_josephs
Posts: 2459
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

TextPad is incapable of matching text containing an arbitrary number of newlines. But if your paragraphs are already each on a single line, you can do something like this:
Find what: (.{1,80})( |$)
Replace with: \1\n

[X] Regular expression
which puts an extra newline at the end of each paragraph.

You have to Replace repeatedly, rather than Replace All once, as the recogniser fails to notice that it's at the beginning of a line when it's positioned immediately after a newline that's just been inserted in the course of the Replace All. This is a bug.

The above assumes you are using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
With WildEdit (http://www.textpad.com/products/wildedit/) your paragraphs don't need to be on single lines:
Find what: (.{1,80})( |$)
Replace with: $1\n

[X] Regular expression
[X] Replacement format

Options
[ ] '.' does not match a newline character [i.e., not selected]
User avatar
tcebob
Posts: 80
Joined: Fri Mar 28, 2003 1:20 am

Post by tcebob »

Thanks for the assistance. Guess I'm asking too much of Reg. Ex., at least in this version. A non-RE solution came from your first suggestion: I set my "txt" Document class to save with hard word-wrap. Works fine. -- Or was that what you had in mind?

tcebob
Post Reply