Find/Replacing with \n not acting as I would expect

7,772 views
Skip to first unread message

Chris Denesha

unread,
Feb 5, 2010, 4:52:27 PM2/5/10
to TextWrangler Talk
Hi all,

This is a little weird, and I'm new to TextWrangler - perhaps I'm
missing something? I tried to google for an answer but didn't see
anything in 5 minutes of searching.

I have some text separated with semi-colons, and I'd like to see each
bit of text on its own line for clarity.

If I enter ; for the Find term and \n for the Replace term, and choose
'Replace' or 'Replace and Find Next' and go through the file, the
semi-colon is replaced and the text segments are bumped down to the next
line as I would expect. If I show invisibles it is a gray character that
looks like a dash with a short downwards line at the right side. If I
hex dump the front document, it is 0x1D = 13 = CR. It does not matter if
I check 'Use Grep' or not. It does not matter what line ending I choose
at the bottom of the window.

If I enter ; for the Find term and \n for the Replace term, and choose
'Replace All' or 'Replace to End', the semi-colon is replaced and the
text segments are NOT bumped down to the next line. If I show invisibles
it is a red upside down question mark. If I hex dump the front document,
it is 0x1A = 10 = LF. It does not matter if I check 'Use Grep' or not.
It does not matter what line ending I choose at the bottom of the window.

I did not expect the inconsistency between Replace and Replace All. I
also did not expect the \n to convert to a newline if I didn't choose
'Use Grep', however I see in Help that there are Special Characters like
this used in Basic searching mode. But then I would expect the Replace
All and Replace to End to work the same as Replace.

If you think it is a bug, I'll submit it.

thanks in advance.

chris


Tom Robinson

unread,
Feb 6, 2010, 3:40:20 AM2/6/10
to textwr...@googlegroups.com
On 2010-02-06, at 10:52, Chris Denesha wrote:

> If I enter ; for the Find term and \n for the Replace term, and choose
> 'Replace All' or 'Replace to End', the semi-colon is replaced and the
> text segments are NOT bumped down to the next line.

Yeah, looks like a bug; I'm seeing it here too (10.6.2) Given how often I use \n I assume it crept in with 3.1

You can work around it by using option-return for the Replace string.

Cheers

Rich Siegel

unread,
Feb 6, 2010, 9:37:23 AM2/6/10
to textwr...@googlegroups.com
On 2/5/10 at 4:52 PM, cden...@gmail.com (Chris Denesha) wrote:

>I have some text separated with semi-colons, and I'd like to see each
>bit of text on its own line for clarity.

For that purpose, use \r, not \n; you should see the desired
behavior in all cases.

R.
--
Rich Siegel Bare Bones Software, Inc.
<sie...@barebones.com> <http://www.barebones.com/>

Someday I'll look back on all this and laugh... until they
sedate me.

Tom Robinson

unread,
Feb 6, 2010, 10:16:45 AM2/6/10
to textwr...@googlegroups.com
On 2010-02-07, at 03:37, Rich Siegel wrote:

> For that purpose, use \r, not \n; you should see the desired behavior in all cases.

Oops—you're right, that's what I normally use.

Chris Denesha

unread,
Feb 6, 2010, 5:44:46 PM2/6/10
to textwr...@googlegroups.com
Rich Siegel wrote:
> On 2/5/10 at 4:52 PM, cden...@gmail.com (Chris Denesha) wrote:
>
>> I have some text separated with semi-colons, and I'd like to see each
>> bit of text on its own line for clarity.
>
> For that purpose, use \r, not \n; you should see the desired behavior in
> all cases.


cool, \r works better, thanks!

Now I think \n should work differently for Replace and Replace and Find
Next. It shouldn't be putting in 0x1D but 0x1A. :)

chris

Reply all
Reply to author
Forward
0 new messages