Replace with newline character

14,724 views
Skip to first unread message

mweisman

unread,
Sep 30, 2011, 12:40:34 PM9/30/11
to BBEdit Talk
I have some very long sql queries that are stored in a single line
with statements separated by a ; to get around a bug in a program I
use that limits me to single line queries. When I need to make changes
to the queries, I like to split them out into multiple lines to make
them readable. Most text editors allow me to do a find and replace to
replace ';' with ';\n' to split them out. BBEdit just inserts a
literal '\n' in place of a new line, even when I have the grep button
clicked.

Is there another way to use a new line as a replacement character?

Thanks,

Michael

--
Michael Weisman

Lee Hinde

unread,
Sep 30, 2011, 12:55:11 PM9/30/11
to bbe...@googlegroups.com
You can type option-return in the replace box after the semi-colon.

Find: ;
Replace ;
<option-return>

Fletcher Sandbeck

unread,
Sep 30, 2011, 12:49:56 PM9/30/11
to bbe...@googlegroups.com
On Sep 30, 2011, at 9:40 AM, mweisman wrote:

Strange, I do, we all do, what you're describing all the time and it works fine. BBEdit recognizes \n as a newline in search/replace. You could also try \r or just copy a newline from a text document and paste it in.

[fletcher]

Doug McNutt

unread,
Sep 30, 2011, 1:47:05 PM9/30/11
to bbe...@googlegroups.com
At 09:49 -0700 9/30/11, Fletcher Sandbeck wrote:

Remember that bbedit works with everything as 16 bit unicode. There, all line ends are Apple style 000D entries.

Regardless of what will come out on a save you have to check for 0D while it's in memory.

It was once true that, for Apple machines, �n, with an OPTION d greek delta as the escape character, was 0D.

Sometime, about when the neXt folks took over, the delta became a \ for the escape as in UNIX and you need to use \r in memory for new versions of bbedit.

So....


search for \r and replace with ;\r in memory. bbedit will honor your choice of \n = 0A when saving the file.

What happens with the other two 16 bit line ends in unicode is undetermined.

--

Applescript syntax is like English spelling:
Roughly, though not thoroughly, thought through.

Rod Buchanan

unread,
Sep 30, 2011, 1:09:29 PM9/30/11
to bbe...@googlegroups.com

Use '\r' in your search. If your file is Unix text (or saved as such) it will be saved as a newline ('\n').

BBEdit's '\r' convention took some getting used to when I switched to the Mac. I assume it is a holdover from the classic Mac days, where text files were carriage-return delimited.

--
Rod Buchanan

Reply all
Reply to author
Forward
0 new messages