The Text Editor Question

Tuesday, December 8th, 2009

800px-Linotype_CRTronic_360Back in college, I had a professor pose an interesting question on an exam. It was worded like this:

“On the back of this paper, write out every keystroke and mouseclick you would take to add five spaces at the beginning of the first 10 lines of a file in a text editor.”

Naturally, some people protested. But he insisted that the literal meaning of the question was to be carried out.

Some students assumed it was a trick question that they didn’t understand, and wrote nothing. Some students write out the entirety of what was necessary to do this in Notepad:

space, space, space, space, space, down, home, space, space, space, space, space, down, home,space, space, space, space, space, down, home,space, space, space, space, space, down, home,space, space, space, space, space, down, home,space, space, space, space, space, down, home,space, space, space, space, space, down, home,space, space, space, space, space, down, home,space, space, space, space, space, down, home,space, space, space, space, space

At the time, I had been learning Vim at the professor’s advice. So, feeling very clever, I wrote this on the back of my paper:

:1,10s/^/     /

In a few days, when the exam was returned, students noticed that the this question had not been graded. The professor answered them:

“Your reward for getting it right is not having to write out an entire page of text to do something trivially simple. If you haven’t followed my advice and learned a good text editor, you waste this much time a hundred times over every time you write a program.”

Invaluable advice for any programmer. Use good tools, and get really good at using them.

[Image Credit]

No Comments

Leave a comment

About | Other Stuff