Feeds

Six things a text editor must do - or it's a one-way trip to the trash

Does your source code editor pass the Verity test?

Top three mobile application threats

The TADREP Test

6. The Tedious And Domain Related Editing Pattern. This is the big one. This is where good programmers' editors really get to show that there are more than just text controls, elaborately decorated with pretty colours and more unused features than Word.

TADREP is a pattern never seen in programming tutorials, but in actual programming-for-money it occurs quite frequently. It comprises taking a block of domain-sourced text like this

0001, 3000, Adam, London
0002, 1000, Bonnie, Manchester
0003, 2000, Catherine, Edinburgh
0004, 3000, David, New York
continues like this for 20 more lines)

and munging it into code of some sort:

db.add("0001", "Adam", "London", 3000);
db.add("0002", "Bonnie", "Manchester", 1000);
db.add("0003", "Catherine", "Edinburgh", 2000);
db.add("0004", "David", "New York", 3000);
et cetera

(Counter nosepick: I realise this isn't a very good example. I couldn't think of one, ok? You do know what I mean, really.)

I claim there are three common ways of achieving this:

  1. Knife-and-forking it by hand, the Yvonne Gumby approach, which is not really on if you have more than three lines;
  2. Contriving some sort of regex search-and-replace, in which case Zawinski's Observation Applies; or
  3. Recording a keyboard macro which, by a very cunning selection of keystrokes, will apply to all the lines that need to be manipulated. Then play it back as many times as needed. Then go back, and fix all the lines it has stuffed.

TextPad has an excellent search-and-replace dialog (non-modal, but goes translucent when it doesn't have focus, so can be left open without getting in the way). Its regexs, however, smell of mothballs. These are formulated to some ancient POSIX standard that omits, for example, the \w character class that everybody enjoys complaining about. Its keyboard macros are adequate.

Sublime recovers some marks for offering the full Perl regex syntax - mysteriously, few editors seem to do this, given that most programming languages now throw it in for free. And, yes, it lets you record keystroke macros.

However, it also offers a whole new way of tackling TADREP.

Danger, gusher

OK, turn down your sensitivity, and lock your British sense of embarrassment into the upright position. I am going to have to do something rather unusual here. I am going to express naked, uncynical enthusiasm.

Sublime's multiple cursor feature is completely top. You select a block of text, press Ctrl + Shift + L (if you are following along on your Mac, just press squiggle squoggle shift Home), and now you have a separate cursor on every line in the block. As you move left or right, they all march together. Cut out a block and paste it somewhere else on the line, and it is repeated n times for n different blocks. Typed characters go in on every line, and Ctrl + Z also operates in parallel.

This is powerful, simple, clever and I have never seen it done quite like this before. Sublime has penetrated my battle-hardened crust. Restore its million points, Mr Scoreboard Runner, and bring me the final results.

Judgment of Verity

I only really performed this test to frighten TextPad into better behaviour in future. The threat of replacement is a more satisfying way of achieving improved performance from applications than conventional techniques such as upgrading or reporting bugs, and approximately as effective.

However, now that I have spent time with Sublime, I confess I will keep it on my hard disk for its show-stopping gadgets, and will in due course register it (they want $70 a shot for a multiplatform licence, which seems reasonable). Damnit, fallen for another gadget.

Post Script: shortly after I wrote the above, we found a bug in a logger which, to my chagrin, I could coax neither TextPad nor Sublime to identify. However, Dave loaded the log file into Notepad++ and displayed it like this:

<Rolf>Can you tell what the problem is yet?</Rolf>

Worse even than this humiliation of my favourites, the bug was initially discovered by my boss. And he first noticed something amiss with the line endings while poking around in - and, dammit, I swore I wasn't going to use this word - while poking around in...

Notepad. ®

Top three mobile application threats

More from The Register

next story
Android engineer: We DIDN'T copy Apple OR follow Samsung's orders
Veep testifies for Samsung during Apple patent trial
This time it's 'Personal': new Office 365 sub covers just two devices
Redmond also brings Office into Google's back yard
Batten down the hatches, Ubuntu 14.04 LTS due in TWO DAYS
Admins dab straining server brows in advance of Trusty Tahr's long-term support landing
Microsoft lobs pre-release Windows Phone 8.1 at devs who dare
App makers can load it before anyone else, but if they do they're stuck with it
Half of Twitter's 'active users' are SILENT STALKERS
Nearly 50% have NEVER tweeted a word
Internet-of-stuff startup dumps NoSQL for ... SQL?
NoSQL taste great at first but lacks proper nutrients, says startup cloud whiz
Windows 8.1, which you probably haven't upgraded to yet, ALREADY OBSOLETE
Pre-Update versions of new Windows version will no longer support patches
Microsoft TIER SMEAR changes app prices whether devs ask or not
Some go up, some go down, Redmond goes silent
Red Hat to ship RHEL 7 release candidate with a taste of container tech
Grab 'near-final' version of next Enterprise Linux next week
Ditch the sync, paddle in the Streem: Upstart offers syncless sharing
Upload, delete and carry on sharing afterwards?
prev story

Whitepapers

Designing a defence for mobile apps
In this whitepaper learn the various considerations for defending mobile applications; from the mobile application architecture itself to the myriad testing technologies needed to properly assess mobile applications risk.
3 Big data security analytics techniques
Applying these Big Data security analytics techniques can help you make your business safer by detecting attacks early, before significant damage is done.
Five 3D headsets to be won!
We were so impressed by the Durovis Dive headset we’ve asked the company to give some away to Reg readers.
The benefits of software based PBX
Why you should break free from your proprietary PBX and how to leverage your existing server hardware.
Securing web applications made simple and scalable
In this whitepaper learn how automated security testing can provide a simple and scalable way to protect your web applications.