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?

Beginner's guide to SSL certificates

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

Remote control for virtualized desktops

More from The Register

next story
Be real, Apple: In-app goodie grab games AREN'T FREE – EU
Cupertino stands down after Euro legal threats
Download alert: Nearly ALL top 100 Android, iOS paid apps hacked
Attack of the Clones? Yeah, but much, much scarier – report
You stupid BRICK! PCs running Avast AV can't handle Windows fixes
Fix issued, fingers pointed, forums in flames
Microsoft: Your Linux Docker containers are now OURS to command
New tool lets admins wrangle Linux apps from Windows
Bada-Bing! Mozilla flips Firefox to YAHOO! for search
Microsoft system will be the default for browser in US until 2020
Facebook, working on Facebook at Work, works on Facebook. At Work
You don't want your cat or drunk pics at the office
Soz, web devs: Google snatches its Wallet off the table
Killing off web service in 3 months... but app-happy bonkers are fine
prev story

Whitepapers

Why cloud backup?
Combining the latest advancements in disk-based backup with secure, integrated, cloud technologies offer organizations fast and assured recovery of their critical enterprise data.
A strategic approach to identity relationship management
ForgeRock commissioned Forrester to evaluate companies’ IAM practices and requirements when it comes to customer-facing scenarios versus employee-facing ones.
5 critical considerations for enterprise cloud backup
Key considerations when evaluating cloud backup solutions to ensure adequate protection security and availability of enterprise data.
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.
Getting ahead of the compliance curve
Learn about new services that make it easy to discover and manage certificates across the enterprise and how to get ahead of the compliance curve.