Reverse order of lines

304 views
Skip to first unread message

Ted Stresen-Reuter

unread,
Mar 8, 2021, 12:15:00 PM3/8/21
to bbe...@googlegroups.com
Hi,

I know this can be done but am not finding the solution.

Given:

Lingo (Macromedia Director)
AppleScript
HyperTalk
HTML
JavaScript
Perl
SQL
Bash
HTTP
PHP
CSS
Visual Basic
ASP (Classic)
XML
XSLT
jQuery
Fusebox for PHP
WordPress
Laravel
React
AlpineJS

I'd like to end up with a list with the items in the reverse order, so, along the lines of:

AlpineJS
React
Laravel
WordPress
Fusebox for PHP
etc.

Note that the sort criteria is the order the lines appear in in the input. Can't BBEdit do this?

Thanks in advance.

Ted Stresen-Reuter

TJ Luoma

unread,
Mar 8, 2021, 12:26:56 PM3/8/21
to BBEdit MailingList
On Mon, Mar 8, 2021 at 12:15 PM Ted Stresen-Reuter <tedmas...@gmail.com> wrote:

> I'd like to end up with a list with the items in the reverse order, so, along the lines of:

I don't know if there's a way to do this directly in BBEdit but you can do this via: 

» Text » Run Unix Command 

and enter `tail -r`

Screenshot:

HTH

Tj

jj

unread,
Mar 8, 2021, 12:27:44 PM3/8/21
to BBEdit Talk

Hi Ted, 

Go to Menu 'Text' > 'Run Unix Command ...', type: "tail -r", choose your preferred output option and click 'OK'.


HTH.

Best regards,

Jean Jourdain

jj

unread,
Mar 8, 2021, 12:28:57 PM3/8/21
to BBEdit Talk
Wow. Parallel thinking happened here ;-)

Ted Stresen-Reuter

unread,
Mar 8, 2021, 12:30:24 PM3/8/21
to bbe...@googlegroups.com
Brilliant. Thank you both!

Ted

--
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/4140f343-e5e1-4522-b7c2-b7c0eedfcb3dn%40googlegroups.com.

Ted Burger

unread,
Mar 8, 2021, 12:39:27 PM3/8/21
to bbe...@googlegroups.com
Sometimes you have to pick the right tool for the job.

I would paste that list into a spreadsheet.
In the next column I would auto fill a number series.
Select it all and sort on the number column in reverse order.
Copy the column of interest and paste it back into Nnedit.

Typing took me much longer than actually doing it would take.

Thanks,
Ted
***********************  Ted Burger  ****************************
t...@tobsupport.com      *********     www.tobsupport.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.

Patrick Woolsey

unread,
Mar 8, 2021, 1:01:29 PM3/8/21
to bbe...@googlegroups.com
Though BBEdit doesn't have any built-in command for doing so[*],
you could certainly apply a _text filter_ which contains any
suitable Unix script (via 'awk', 'sed', Perl, Python, etc.)

For instance, please make sure your list is followed by a
trailing linebreak, then create & apply the following:
========
#!/bin/sh
perl -e 'print reverse <>'
========

[*: Please note that Text -> Sort Lines with "Reverse sort"
enabled will re-sort the whole list into reverse alpha order
rather than just 'flipping' it.]


Regards

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



On 3/8/21 at 12:14 PM, tedmas...@gmail.com (Ted
Stresen-Reuter) wrote:

>Hi,
>
>I know this can be done but am not finding the solution.
>
>Given:
>
>Lingo (Macromedia Director)
>AppleScript
>HyperTalk
>HTML
>[...]

Christian Boyce

unread,
Mar 8, 2021, 2:26:31 PM3/8/21
to bbe...@googlegroups.com
You can do it in AppleScript, operating on selected text in BBEdit if you want. This isn’t the one-liner that the Unix people are giving you but it still works:

tell application "BBEdit"
set myDoc to document 1
set mySelection to the selection
set theList to contents of lines of mySelection


set newOrder to ""


repeat with aParagraph in theList
set newOrder to aParagraph & return & newOrder
end repeat
set selection to newOrder
end tell



--
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/CAKAQjifrOD%3DkExWSCng3LHxaVVmWoaRJgFLeWf6j5fSnM7WqUQ%40mail.gmail.com.

Ted Stresen-Reuter

unread,
Mar 8, 2021, 3:18:22 PM3/8/21
to bbe...@googlegroups.com
On Mon, Mar 8, 2021 at 6:01 PM Patrick Woolsey <pwoo...@barebones.com> wrote:

[*: Please note that Text -> Sort Lines with "Reverse sort"
enabled will re-sort the whole list into reverse alpha order
rather than just 'flipping' it.]


Noted! And this was the reason I wrote to the list in the first place. In the back of my head there was a vague memory that it was possible but I simply couldn't find it.

Thanks again to all, even for the AS solution! 

Christopher Stone

unread,
Mar 8, 2021, 5:18:57 PM3/8/21
to BBEdit-Talk
On 03/08/2021, at 11:14, Ted Stresen-Reuter <tedmas...@gmail.com> wrote:
I know this can be done but am not finding the solution.


Hey Ted,

I'd use `gtac` in the shell myself, but I've got the GNU Core Utilities installed on my system.  (Installs easily with MacPorts or HomeBrew.)

As for the AppleScript route:



set AppleScript's text item delimiters to linefeed
tell application "BBEdit"
    set selection to (reverse of (get contents of lines of selection)) as text
end tell



--
Best Regards,
Chris

Reply all
Reply to author
Forward
0 new messages