Add space between paragraphs

96 views
Skip to first unread message

Kim Mosley

unread,
May 27, 2023, 7:40:55 AM5/27/23
to BBEdit Talk
How do I add a space between paragraphs? It seems every line is showing \n?

Thanks, 

Kim
Book of Serenity.txt

Johnny Ragadoo

unread,
May 29, 2023, 10:52:05 AM5/29/23
to BBEdit Talk
I'd like to learn how to do this, too. BBEdit would be a fantastic companion editor for desktop publishing apps like Affinity Publisher if newlines were paragraph separators.

Bruce Van Allen

unread,
May 29, 2023, 11:38:40 AM5/29/23
to BBEdit Talk
>> if newlines were paragraph separators.


It’s easy to find each “\n” and replace it with with “\n\n", to provide space between lines, but I have a feeling that’s not what you’re thinking of.

Keep in mind that BBEdit is a text editor, not a word processor or page layout app. In text, “\n” stands for a newline; but it doesn’t carry any of the paragraph formatting that a word processor might provide via “space before” or “space after” in its paragraph formatting controls.

When I import text into an app like Affinity Publisher, Adobe InDesign, etc, I rely on those apps to provide the paragraph formatting.

Now, another newline issue can be that paragraphs themselves are “hard-wrapped”, meaning that “\n" is used WITHIN paragraphs to make the lines wrap. In those cases, my goal is usually to remove the “\n”s except where I really want to end the line. That’s another easy find/replace op. BBEdit provides controls to flip “soft wrapping" on/off, so I can see a whole long line wrapped to a viewable width if necessary, but without inserting newlines to make it wrap.

But really, I’m guessing here what you both want. Examples?

— Bruce

_bruce__van_allen__santa_cruz_ca_

Kim Mosley

unread,
May 29, 2023, 12:06:50 PM5/29/23
to bbe...@googlegroups.com
Thanks Bruce.

Soft wrapping is off… so I don’t know if this can be fixed other than manually adding a space after each paragraph.

example.txt

Rod Buchanan

unread,
May 29, 2023, 12:17:30 PM5/29/23
to 'Dmitry Markman' via BBEdit Talk

If you are looking to change this

this is paragraph 1.
this is paragraph 2.

to this

this is paragraph 1.

this is paragraph 2.

This search/replace should do it:

Search: \n
Replace: \n\n

Make sure Grep is enabled.

HTH,

— 
Rod



On May 29, 2023, at 11:06 AM, Kim Mosley <mrkim...@gmail.com> wrote:

Thanks Bruce.

Soft wrapping is off… so I don’t know if this can be fixed other than manually adding a space after each paragraph.

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/DF48E0AB-FB27-4F14-81B9-8D6D51D35F4D%40gmail.com.
<example.txt>

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/A0DB5110-1BEA-40AF-B73D-88F19ECFA9AB%40cruzio.com.

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/DF48E0AB-FB27-4F14-81B9-8D6D51D35F4D%40gmail.com.

Kim Mosley

unread,
May 29, 2023, 12:20:59 PM5/29/23
to bbe...@googlegroups.com
No, that doesn’t work here because there is a \n at the end of every line… and it is not soft wrapped. When I do what you suggested I get this:

The practice of yoga now comes in as a means of actually making this detachment from mental

construction a practical possibility. In order that this detachment not become nihilistic or otherwise

aberrated, and that altered states of consciousness not merely be substitued as objects of fixation,

the doctrine here introduces the principles of the relative and real natures of phenomena concealed

beneath the conceptualized description.

The relative or dependent nature is the nature of phenomena as products of interactions of

conditions. A generalized example of this commonly used for illustration is the interaction of

sense faculties, sense consciousnesses, and sense data. This is the raw material of the selection and

organizational process of mental construction. Since the faculties, consciousnesses, and data

cannot be apprehended in themselves, outside of their mutual interrelationship, there is no way of


Bruce Van Allen

unread,
May 29, 2023, 12:24:08 PM5/29/23
to bbe...@googlegroups.com
And do you mean that with soft-wrapping off, a paragraph is still broken into multiple lines with “\n”s?

If I were to import that to a page layout app, I would first remove all of those interior “\n”s in BBEdit; otherwise they’ll mess up the page layout’s formatting.

— Bruce

_bruce__van_allen__santa_cruz_ca_

Johnny Ragadoo

unread,
May 29, 2023, 12:27:28 PM5/29/23
to BBEdit Talk
Hi, Bruce, thanks for your suggestions.

Affinity Publisher is really cool, but it's not the best for editing text. BBEdit excels at editing text.

I think I see how to do this.

The challenge is to edit with visible paragraph breaks that reflow with text window changes. After pasting into Affinity, a paragraph needs to end with a newline. Individual lines do not.

So here's a setup I'm going to play with.

In BBEdit's Edit->Text options, soft wrap text to window width.

End paragraphs with (shudder) two carriage returns.

Save the file.

Replace all \n\n with \n. Copy and paste into text frames in Affinity. Affinity is happy.

In BBEdit, use File->Revert to get paragraph breaks back.

The extra steps are save, replace all, and revert in that order.

I think I can live with that if my overworked right pinky can live with all the extra returns. :-)

I need to take another look at BBEdit's notebook feature. That might be a nice way of writing copy for an Affinity brochure, keeping all the text in one nice bundle.

Ooh, just realized - I have Keyboard Maestro installed. I might either make the return key get doubled, or make shift-enter two return keys.

Have a great day!

jj

unread,
May 29, 2023, 1:13:05 PM5/29/23
to BBEdit Talk
@Kim Mosley,

The linked document you provide already contains paragraphs separated by a blank line.
For what ever reason the export/copy/paste or document styling kills those paragrahs separations.
But if you copy the content of the document with your browser developer tools and paste it in BBEdit,
you will see that the paragraphs are indeed already blank line separated.

HTH,

Jean Jourdain

Screenshot 2023-05-29 at 19.04.19.png

Bruce Van Allen

unread,
May 29, 2023, 1:16:07 PM5/29/23
to BBEdit Talk
> On May 29, 2023, at 9:20 AM, Kim Mosley <mrkim...@gmail.com> wrote:
> No, that doesn’t work here because there is a \n at the end of every line… and it is not soft wrapped. When I do what you suggested I get this:


How much text are you dealing with? Is this a repeating task? Do you have any control over the original texts you’re working on?

I would try to remove those line-breaks internal to the paragraphs as early in my processing as possible, or alter the form they come to me in if I can control that. Each paragraph (which might have multiple sentences) should be on one line with soft-wrapping off in the text editor (BBEdit).

Here’s a possible hacky approach, from looking at the sample text you posted:

Hacky Step 1: Insert newlines before “paragraphs”:

Search for an uppercase letter at the start of a line:
^([A-Z])

and replace it with:
\n\1

BBEdit has great documentation of the above find/replace expressions, but briefly,

^ denotes the start of a line;

[A-Z] stands for one character of the range A to Z (uppercase standard English characters, so I’m making some assumptions here);

() around the [A-Z] “captures" whatever character it found.

In the replace pattern, \n is our friend the newline, and \1 stands for what was captured in the search pattern - that first character of the line.

That will put a newline “\n” in front of what is likely to be the start of one of your paragraphs. So you won’t have to do that many times manually. But you will need to check it over, because this isn’t bullet-proof.

Step 2: Remove internal line breaks:

Once you have those newlines inserted before each set of lines that you consider a paragraph, you'll want to remove the internal line breaks with the paragraphs.

After Hacky step 1, your “paragraphs” now have single newlines internally and are separated by two newlines. So your search for the internal newlines would be for a “\n" surrounded by space-bar spaces, characters, or punctuation but no adjacent newlines.

Minimalistic search pattern:
([^\n])\n([^\n])

This finds a \n with any character NOT an \n on either side; the ^ inside the square brackets means “not”.

Replace with:
\1 \2

This will put the surrounding captured characters back with a spacebar space between them where the \n was. This might not be exactly what you need, depending on how those internal line breaks originally got into your “paragraphs”. Might be some extra spacebar spaces lying around.

So test on a copy of your file. Also turning on BBEdits “Show Invisibles” can be helpful for this work
> To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/B4C0D58D-A103-4AE3-AD1F-BFA1DE12BB1E%40gmail.com.

Ron Catterall

unread,
May 29, 2023, 5:23:00 PM5/29/23
to bbe...@googlegroups.com
1.  replace \n\n by qwerty

2. replace \n by a space

3. replace qwerty  by \n<anything you want>\n
>>> send an email tobbedit+u...@googlegroups.com.
>>> To view this discussion on the web
>>> visithttps://groups.google.com/d/msgid/bbedit/DF48E0AB-FB27-4F14-81B9-8D6D51D35F4D%40gmail.com.
>>> send an email tobbedit+u...@googlegroups.com.
>>> To view this discussion on the web
>>> visithttps://groups.google.com/d/msgid/bbedit/DF48E0AB-FB27-4F14-81B9-8D6D51D35F4D%40gmail.com.
>>
>>
>> --
>> This is the BBEdit Talk public discussion group. If you have a
>> feature request or need technical support, please email
>> "sup...@barebones.com" rather than posting here. Follow @bbedit on
>> Twitter: <https://twitter.com/bbedit>
>> ---
>> You received this message because you are subscribed to the Google
>> Groups "BBEdit Talk" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email tobbedit+u...@googlegroups.com.
>> To view this discussion on the web
>> visithttps://groups.google.com/d/msgid/bbedit/B97AB4A5-932D-48EE-A4DA-B0D2F895C10E%40sofstats.com
>> <https://groups.google.com/d/msgid/bbedit/B97AB4A5-932D-48EE-A4DA-B0D2F895C10E%40sofstats.com?utm_medium=email&utm_source=footer>.
>
> --
> This is the BBEdit Talk public discussion group. If you have a feature
> request or need technical support, please email
> "sup...@barebones.com" rather than posting here. Follow @bbedit on
> Twitter: <https://twitter.com/bbedit>
> ---
> You received this message because you are subscribed to the Google
> Groups "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to bbedit+un...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/bbedit/B4C0D58D-A103-4AE3-AD1F-BFA1DE12BB1E%40gmail.com
> <https://groups.google.com/d/msgid/bbedit/B4C0D58D-A103-4AE3-AD1F-BFA1DE12BB1E%40gmail.com?utm_medium=email&utm_source=footer>.

--
Ron Catterall
r...@catterall.net
Fedora 38 Linux


--
Ron Catterall
ro...@catterall.net
Reply all
Reply to author
Forward
0 new messages