First Use - quick way to get a list of numbers for output

327 views
Skip to first unread message

Lorenz Groth

unread,
Dec 30, 2021, 2:53:24 PM12/30/21
to BBEdit Talk
Hello!
I used to use programs like maple (math software) and latex for text editing. But I am new at programming other stuff. 
What I want to learn is how to produce a simple list of numbered word such as
word01
word02
word03
word04
....
automatically to not have to do this by typing.
Can anyone tell me how to do that with BBEdit? I guess there will be some loop stuff, for, while, if, do and something like this. But I have NO experiences with that in BBEdit. All I got is this
 BBEditWorksheet.png and
BBEditVersuchCompiler.png
I hope my problem is understandable. I write in German English...

Ted Burger

unread,
Dec 30, 2021, 3:20:45 PM12/30/21
to bbe...@googlegroups.com
Not what you asked for,but I would use a spreadsheet for that.

Put your words in the first column.
In the second column have it fill down with a series of numbers.
Now select both columns and copy.
Paste in BBEdit and delete the tab characters.

Ted

Sent from the Burger's iPad

On Dec 30, 2021, at 2:53 PM, Lorenz Groth <lorenz...@gmail.com> wrote:

Hello!
--
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/727fc16f-a0a2-4c0c-813f-3ff40381968fn%40googlegroups.com.

jj

unread,
Dec 30, 2021, 3:50:25 PM12/30/21
to BBEdit Talk
Hi Lorenz,

Execute this snippet of AppleScript with Script Editor:

    tell application "BBEdit"
        set vContents to ""
        repeat with i from 1 to 15
            set vNumber to i as string
            if i < 10 then
                set vNumber to "0" & vNumber
            end if
            set vContents to vContents & "word" & vNumber & linefeed
        end repeat
        make new document with properties {contents:vContents}
    end tell

HTH

Jean Jourdain

Lorenz Groth

unread,
Dec 30, 2021, 3:59:47 PM12/30/21
to BBEdit Talk
Thanx to Ted for your quick reaction and a semi-solution. That works. 
But it would be really nice to know how to generate such repeating terms. Because I need this often and in different ways.
So I'm glad for today but still interested in a more professional solution.

Patrick Woolsey

unread,
Dec 30, 2021, 4:59:11 PM12/30/21
to bbe...@googlegroups.com
On 12/30/21 at 3:59 PM, lorenz...@gmail.com (Lorenz Groth) wrote:

>Thanx to Ted for your quick reaction and a semi-solution. That
>works. But it would be really nice to know how to generate such
>repeating terms. Because I need this often and in different ways.
>So I'm glad for today but still interested in a more professional solution.


Here's a quick and relatively simple solution, based on a shell
script and making use of BBEdit's support for _text filters_.

1. Create a new document within BBEdit.

2. Copy the text below (within the equal signs) and paste it
into the document:

====
#!/bin/sh
for i in {1..50}
do
echo "word$i"
done
====

3. Save the document to disk with a meaningful name, e.g. "make
numbered words.sh".

4. Choose the BBEdit -> Folders -> Text Filters menu item.

This action should cause the Finder to open the "Text
Filters" subfolder
of BBEdit's app support folder.

5. Place the script you just created into the "Text Filters" subfolder.

You can now invoke the text filter you just created by selecting
it in the Text -> Apply Text Filter submenu, with just one
caveat -- but an important one:

Please be sure to select at least one character (which can be
just a space) before applying this filter. (If you do _not_ do
this then the filter will replace the entire contents of the
active document with its own output.)


Regards

Patrick Woolsey
==
Bare Bones Software, Inc. <https://www.barebones.com/>

Luis Speciale

unread,
Dec 30, 2021, 5:08:33 PM12/30/21
to bbe...@googlegroups.com
> how to produce a simple list of numbered word such as
> word01
> word02
> word03
> word04

Open a new document. Change the wrap text option to none.
Now you can select vertically (right click).

Make carriage returns (the number the words you need)

Now go to Text>Add/Remove line numbers
Make your choice
Then make a vertical selection before the line and add your word

Christopher Stone

unread,
Dec 30, 2021, 7:38:01 PM12/30/21
to BBEdit-Talk
On Dec 30, 2021, at 13:49, Lorenz Groth <lorenz...@gmail.com> wrote:
What I want to learn is how to produce a simple list of numbered word such as
word01
word02
word03
word04


Hey Lorenz,

The most direct method is probably to use a text filter like so:



#!/usr/bin/env bash

seq -w 200 | sed s'!^!Word!'



This filter is easily adjusted for length and will automatically pad the numbers appropriately.

It would be relatively easy to create a pop-up entry field for you to change the word(s) and sequence number at will.



BBEdit's text filters go here:

~/Library/Application Support/BBEdit/Text Filters/

And are accessed from:

BBEdit › Text › Apply Text Filter › ...


--
Best Regards,
Chris

Christopher Waterman

unread,
Dec 30, 2021, 7:47:45 PM12/30/21
to bbe...@googlegroups.com, Lorenz Groth
Hello,

I recently discovered this solution for this kind of thing. I use the unix command: ‘seq' with the the -f flag and BBEdit’s Run Unix Command.

Seq creates sequences of numbers, the -f flag allows you to use a formatted string as output.

So to produce:
word01
word02
word03
word04

I’d use the command:
seq -f 'word%02g’ 10

To produce:
Appt: 103
Appt: 104
Appt: 105
Appt: 106
Appt: 107
Appt: 108
Appt: 109

I’d use:
seq -f 'Appt: %g' 103 109

You can test this on the command line (Terminal.app) but even better under the Text menu, BBEdit has the Run Unix Command. It replaces the document text or the selection with the output of the command.

On the command line run ‘man printf’ to learn about formatted strings. I think this will be very useful for you.
Also check out ‘man seq’ to understand the seq command better.
— Chris(topher)?



Chris

unread,
Dec 30, 2021, 9:15:19 PM12/30/21
to bbe...@googlegroups.com, Lorenz Groth
I made a mistake. 
seq -f 'word%02g’ 10

Should be:
seq -f 'word%02g’ 4

Sorry 
--Chris(topher)?

On Dec 30, 2021, at 4:47 PM, Christopher Waterman <ch...@rustydogink.com> wrote:

Hello,

Tom Robinson

unread,
Dec 30, 2021, 9:54:42 PM12/30/21
to BBEdit Talk
I’ve always used option-click for that.

Bare Bones removed the restriction of needing unwrapped text a version or 2 ago :]

Cheers

Reavis

unread,
Dec 30, 2021, 10:11:56 PM12/30/21
to bbe...@googlegroups.com

Chris,

 

Thanks for your informative series of posts. I've tried running the various seq commands in them. All work except for:

 

seq -f 'word%02g’ 10

 

When I try this, the Terminal (macOS 11.13.1; zsh) returns:

 

quote>

 

Nothing I enter after the > has worked. I tried to find help online, but nothing I found about the seq command and macOS mentions quote>. If you can shed any light on this, I'll be grateful.

 

 

Cheers,

Marc

 

Lorenz Groth

unread,
Dec 30, 2021, 10:11:56 PM12/30/21
to BBEdit Talk
Thanx a lot Jean! That's exactly what I was looking for. There are some trouble with latex syntax (such as command with "\" and "{}" and stuff) that should replace "word" but I'll find way to fix that. So my problem is solved! And I have a good example of how to use BBEdit :-)

Bruce Van Allen

unread,
Dec 30, 2021, 10:49:57 PM12/30/21
to bbe...@googlegroups.com
Reavis wrote on 2021-12-30 6:31 PM:
> Thanks for your informative series of posts. I've tried running the
> various *seq* commands in them. All work except for:
>
> seq -f 'word%02g’ 10
>
> When I try this, the Terminal (macOS 11.13.1; zsh) returns:
>
> quote>

That last output means that the Terminal is expecting a closing quote
mark. It looks like you have a straight single quote at the start, but a
printer's ("curly") quote at the end.

Try it with the same in both places.

seq -f 'word%02g' 10

HTH

--
    - Bruce

_bruce__van_allen__santa_cruz__ca_

Christopher Waterman

unread,
Dec 31, 2021, 12:26:17 AM12/31/21
to bbe...@googlegroups.com
Marc,

Bruce is correct, I let a curly quote get in there somehow. 

Needing a sequence of numbers does come up. The seq command is a nice one to have on hand.
The basic form is easy to remember:  seq <start num> <end num>

Have a great new year,
Chris




Reply all
Reply to author
Forward
0 new messages