How to format this text so it expands and fits page width?

48 views
Skip to first unread message

David J

unread,
Aug 19, 2021, 1:16:28 PM8/19/21
to BBEdit Talk
Hello,

I've got a bunch of files that were cleaned up so they are just text. The text looks fine, except I can't for the life of me figure out how to get it to fill up horizontal space so I can read them like a pdf/document. I've played around with hard/soft wrap options for hours and the text still stays in a skinny horizontal format. Can someone give me a pointer how to reformat the text (in bulk) so it fits the page width?

looks like: 
you do it's a trap if you do go down the
path that's already laid for you it's
going to take you to all the
destinations that are already known it's
going to take you to all of the places
that instinct drove the people before
you but if you want to go somewhere
unique if you want to go somewhere that
only you would go if you want to create
something new and really live a life
that was meant for you because it's
literally crafted by you you have to
take the first steps on faith and as
Rumi said as you start to walk out on
the way the way appears so as you're
 

Rich Siegel

unread,
Aug 19, 2021, 1:18:00 PM8/19/21
to BBEdit Talk
On 19 Aug 2021, at 13:16, David J wrote:

> Hello,
>
> I've got a bunch of files that were cleaned up so they are just text. The
> text looks fine, except I can't for the life of me figure out how to get it
> to fill up horizontal space so I can read them like a pdf/document. I've
> played around with hard/soft wrap options for hours and the text still
> stays in a skinny horizontal format. Can someone give me a pointer how to
> reformat the text (in bulk) so it fits the page width?

"Remove Line Breaks" on the Text menu ought to do the job.

R.


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

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

David J

unread,
Aug 19, 2021, 2:01:34 PM8/19/21
to BBEdit Talk
Oops, apparently learning Google groups too and sent a response to Rich private.

"Better to keep this on the group. :-)
Once it's unwrapped you can turn on Soft Wrap, or use Hard Wrap to reflow it to a specific width."

This worked, thanks!
 

David J

unread,
Aug 21, 2021, 9:07:07 PM8/21/21
to BBEdit Talk
Quick additional questions:

If I have multiple files open, can I remove line breaks from them all at once? I've selected all open documents that are in the side tabs, but the remove line breaks option is greyed out.

Is this something that I need to do some kind folder search/multi-file search and grep? They are all in the same folder.  I'm assuming the bulk edit operation to hard wrap text is similar to doing remove line breaks in bulk?

I've searched in the manual for bulk edit operation and the faq and I clearly must not know the correct wording for this. Thank you for any pointers

Greg Raven

unread,
Aug 22, 2021, 9:44:46 AM8/22/21
to BBEdit Talk
I'll bet you could create a Text Factory that does this, although I haven't tried it myself.

Christopher Stone

unread,
Aug 22, 2021, 6:04:45 PM8/22/21
to BBEdit-Talk
On Aug 21, 2021, at 20:07, David J <future...@gmail.com> wrote:

If I have multiple files open, can I remove line breaks from them all at once? I've selected all open documents that are in the side tabs, but the remove line breaks option is greyed out. 


Hey David,

You can do something like this:

--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2021/08/22 16:43
# dMod: 2021/08/22 16:43 
# Appl: BBEdit
# Task: Remove Line Breaks from Text Documents of Project Window 1.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Remove, @Line, @Breaks, @Project, @Window
--------------------------------------------------------

tell application "BBEdit"

    

    set docList to text documents of project window 1

    

    repeat with theDoc in docList
        tell theDoc's text to remove line breaks
    end repeat

    

end tell

--------------------------------------------------------

Note that this works only on documents open in the front project window.

The script can be altered to operate on any open document.

--
Best Regards,
Chris


David J

unread,
Aug 22, 2021, 11:58:01 PM8/22/21
to BBEdit Talk
Hi Chris,

 Since the end goal was to get the text so I could hard wrap it by removing all line breaks first. Is there any easy way to add an additional hard wrap on all open documents to the above script? Or is it possible to alter it so I could run hard wrap on all open documents as a second operation? Well beyond my understanding so really appreciate what you whipped up there.

With respect, David

Christopher Stone

unread,
Aug 23, 2021, 1:28:34 PM8/23/21
to BBEdit-Talk
On Aug 22, 2021, at 22:58, David J <future...@gmail.com> wrote:
Since the end goal was to get the text so I could hard wrap it by removing all line breaks first. Is there any easy way to add an additional hard wrap on all open documents to the above script?


Hey David,

Sure.

--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2021/08/22 16:43
# dMod: 2021/08/23 12:27
# Appl: BBEdit
# Task: Remove Line Breaks from Text Documents of Project Window 1.
#     : Then Hard Wrap to the Given Length.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Remove, @Line, @Breaks, @Project, @Window
--------------------------------------------------------
property hardWrapWidth : 70
--------------------------------------------------------

tell application "BBEdit"

    

    set docList to text documents of project window 1

    

    repeat with theDoc in docList
        tell theDoc's text
            remove line breaks
            hard wrap width hardWrapWidth
        end tell
    end repeat

    

end tell

--------------------------------------------------------


--
Best Regards,
Chris

David J

unread,
Aug 24, 2021, 11:25:13 AM8/24/21
to BBEdit Talk
This worked well to clean it up. Now I can read these at a proper width. Thank you!

David J

unread,
Aug 24, 2021, 11:39:55 AM8/24/21
to BBEdit Talk
Oh, one last thing. Is there a save all command available after doing this? I read the manual and saw:

 "Here's a new (dynamic) command on the File menu: "Save All in Window". The factory default keyboard equivalent is Command-Option-Shift-S. This is enabled if any (or the only) document in the front window has unsaved changes; choosing it will save all documents in the front window."

That dynamic command doesn't show up after I run the script. The keyboard shortcut doesn't seem to be saving all open files either. Hmmm. Thanks for any pointers.

David J

unread,
Aug 24, 2021, 11:46:19 AM8/24/21
to BBEdit Talk
I figured it out. Selected all that are open and was able to save them. Thanks again!

Christopher Stone

unread,
Aug 24, 2021, 9:32:23 PM8/24/21
to BBEdit-Talk
On Aug 24, 2021, at 10:39, David J <future...@gmail.com> wrote:

Oh, one last thing. Is there a save all command available after doing this?


Hey David,

AppleScript can do many things...

--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2021/08/22 16:43
# dMod: 2021/08/24 20:30
# Appl: BBEdit
# Task: Remove Line Breaks from Text Documents of Project Window 1.
#     : Then Hard Wrap to the Given Length.
#     : Then save each document.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Remove, @Line, @Breaks, @Project, @Window
--------------------------------------------------------
property hardWrapWidth : 70
--------------------------------------------------------

tell application "BBEdit"

    

    set docList to text documents of project window 1

    

    repeat with theDoc in docList
        tell theDoc
            tell its text
                remove line breaks
                hard wrap width hardWrapWidth
            end tell
            save

David J

unread,
Aug 25, 2021, 2:55:42 PM8/25/21
to BBEdit Talk
Thanks, I've been trying to clean up text for my elderly father to read,  old journal entries, highlights and whatnot. This is really helpful.

I have one more question I'll ask in another thread and then try to figure out more on my own for a while.
Reply all
Reply to author
Forward
0 new messages