Pro-Tip 2: Text Manipulation With Sublime Text 2
Today I'm going to try and regain some of the reputation I lost the other week when I blogged a "pro tip", which, it turns out, wasn't very pro at all. Talk about egg on my face!
In response to blog Dragon Cotterill pointed me to Sublime Text 2, which did was took me 5 steps in one very simple step. Doh.
I'm now a convert to Sublime Text and using for allsorts of stuff. It's worth a look at if you haven't seen it already.
Anyway, last week I needed to create a Domino-based dropdown list of countries of the world, along with their ISO-3166 codes. The list is available here.
After copy-pasting direct from that webpage in to Sublime Text I had was what you see below. Whereas, what I wanted was a list in the Notes-friendly format "Country Name|CODE".
Notice in the lower part of the shot above I've got the Search/Replace function open and have entered the following Regular Expression:
^([A-Z]{2})\s{0,}(.*)$
This looks for a two-letter code at the start of a line, followed by some whitespace, followed by some more text and then the end of a line. It returns matches to the parts inside parentheses as "group matches". In this case the first group match is the two digit code and the second is the country name.
In the "Replace With" box I've told it to change each line to be the group 2 match, then a vertical bar and then the group 1 match. The result looks like this:
And that's ready to paste directly in to a Notes field!
It just a matter of getting used to Sublime. I am an avid Textpad user. I still am for some things such as dealing with large log files and NSDs. But for manipulating the text and writing scripts, Sublime is right up there in flexibility.
As with anything, it's a matter of finding the right tool for the job.
Reply
That's a nice tool. I've long been a fan of EditPlus3 and have recently been getting to know notepad++. Sublime looks like something the toolbox needs for more regex intensive work. Thanks, guys!
Reply
Yes, thank you both very much!!! I too typically use Notepad++ but I like what I see.
Reply