Paragraph reformat

General questions about using TextPad

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

Post Reply
sgb
Posts: 7
Joined: Wed May 03, 2006 1:01 pm
Location: UK
Contact:

Paragraph reformat

Post by sgb »

I'm new to Textpad...

I'm trying to make a macro that behaves a bit as EditReformat.

What I actually want is (a) replace all multiple white space in a paragraph with one space except for the initial white space at the start of the first line and (b) reformat that text to the right margin as specified by wordwrap at most but with the left margin using the indent (tabs and spaces) of the first line.

Thus (using . for a space and ---- for a tab)

Before:

----..The.quick..brown.
fox.jumps....over----the..----lazy
dog

After

----..The.quick.brown.fox
----..jumps.over.the.lazy
----..dog

Any suggestions? I'd like it to work on documents where a paragraph already has hard lineends, thus a para-end is a blank line.

Thanks.

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

Post by ben_josephs »

Join all the lines of each paragraph: Edit | Join Lines (Ctrl+J).

Compress all inter-word white space into single spaces:
Find what: ([^\t ])[\t ]+
Replace with: \1 (There's a space at the end of that.)

[X] Regular expression
Reformat the paragraphs: Edit | Reformat (Ctrl+Shift+J).

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

[X] Use POSIX regular expression syntax
Post Reply