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?

Secure remote control for conventional and virtual desktops

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. ®

Boost IT visibility and business value

More from The Register

next story
The Return of BSOD: Does ANYONE trust Microsoft patches?
Sysadmins, you're either fighting fires or seen as incompetents now
Microsoft cries UNINSTALL in the wake of Blue Screens of Death™
Cache crash causes contained choloric calamity
Munich considers dumping Linux for ... GULP ... Windows!
Give a penguinista a hug, the Outlook's not good for open source's poster child
Time to move away from Windows 7 ... whoa, whoa, who said anything about Windows 8?
Start migrating now to avoid another XPocalypse – Gartner
You'll find Yoda at the back of every IT conference
The piss always taking is he. Bastard the.
HANA has SAP cuddling up to 'smaller partners'
Wanted: algorithm wranglers, not systems giants
prev story

Whitepapers

Endpoint data privacy in the cloud is easier than you think
Innovations in encryption and storage resolve issues of data privacy and key requirements for companies to look for in a solution.
Implementing global e-invoicing with guaranteed legal certainty
Explaining the role local tax compliance plays in successful supply chain management and e-business and how leading global brands are addressing this.
Top 8 considerations to enable and simplify mobility
In this whitepaper learn how to successfully add mobile capabilities simply and cost effectively.
Solving today's distributed Big Data backup challenges
Enable IT efficiency and allow a firm to access and reuse corporate information for competitive advantage, ultimately changing business outcomes.
Reg Reader Research: SaaS based Email and Office Productivity Tools
Read this Reg reader report which provides advice and guidance for SMBs towards the use of SaaS based email and Office productivity tools.