How to create line breaks after punctuation?

6,900 views
Skip to first unread message

Stella

unread,
Dec 12, 2011, 10:38:24 PM12/12/11
to TextWrangler Talk
I'm new to TextWrangler, and I copied a long document from Word into
TextWrangler document. It's poetry, and I'm wondering if/how to create
line breaks where the program finds punctuation--ie a comma or period.
Does anyone know the most efficient way to do this? Is it via search
and replace, or via sort lines?

Thanks so much!

Thomas Humiston

unread,
Dec 13, 2011, 1:21:11 AM12/13/11
to textwr...@googlegroups.com
Sorting is good if you want to re-order the lines. Probably not good for poetry, however.

Try this: In the Find dialog, see that the Grep box is checked.
Search for: [,\.]
Replace with: &\r

The brackets mean "match anything listed here". Since the period (or "dot") has a special meaning in Grep searches -- it's normally used as a wildcard character that'll match anything -- we put a backslash (\) in front of it so TextWrangler knows we actually wish it to match a period only. So the search pattern as a whole says, "match a comma or a period". (You can throw in a semicolon or anything else, too, as needed.)

The replacement pattern says "take what you found (represented by "&") and add a break (\r) after it".

For more, see Help > User Manual > Searching with Grep.

- TH

Stella

unread,
Dec 13, 2011, 6:23:52 PM12/13/11
to TextWrangler Talk
Thanks so much!
Reply all
Reply to author
Forward
0 new messages