Yan Pritzker photographer, entrepreneur, software engineer, musician, skier

Blog :: Git Workflows Book :: Dotfiles :: Photography :: About Me

TwitterCounter for @skwp

Get the news feed
Get updates by email
Follow me on twitter

hello, i'm yan

I am a photographer, entrepreneur, software engineer, guitarist, climber, and telemark skier

This blog is about startups, blogging, Ruby On Rails, virtualization and cloud computing, photography, customer service, marketing, ux and design, git, and lots more.

I am the chief technical something or other at Reverb.com - The Marketplace for Musicians. We're hiring web designers!

Recent Tweets

Selected Reading

Archives

Contact

Reach me at yan at pritzker.ws

5 ways to get insane productivity boosts for coders

Posted 3 October 2006 @ 5pm in software, thoughts



Submit to HN

It is said that really good programmers are orders of magnitude more productive than the average ones. What makes this the case? And why isn’t this the case in other industries? I believe the answer lies in that computers are very good at automation. And good programmers know how to make computers do what they do best: that is, automate things. The best programmers are the ones who undersand this so well that they will not only solve the task they are directly working on, but learn to automate every step of the very process that leads them there. Here are some useful tips that may seem like common sense, except that most good programmers never go from good to great because of this.

1. Never look when you can search. Why look when you can search? Even if you’re looking for one item in a list of ten, it is always faster to type three or four characters than to scan the list with your eyes. Most reasonable environments including the popular editors and IDEs offer at least some way to do inline completion-based searching. Hit the shortcut and type the first couple characters identifying what you’re looking for and you’re there.

2. Don’t repeat yourself. Are you typing the same thing over and over? Make a shortcut out of it. Use global keyboard shortcuts to call up your favorite apps. On OSX/Unix,

alias

is your friend. Make two character mnemonic aliases for everything. Corollary: Never Mouse when you can Key. A good approach to learning built in shortcuts is every time you reach for your mouse, make a note of the shortcut key for the action you’re performing, and then let go of the mouse and execute the action from the keyboard. Then do it two more times.

3. Learn a scripting language. Bash, Perl, Ruby, Python. Pick one and learn it. Perl used to be the king of one liners. These days I find myself reaching for ruby more because I use it on a daily basis anyway. Automate common tasks with bash and ruby.

4. Learn an editor. I mean a real editor. Both vi and emacs are acceptable choices here. Some people like TextMate but after PeepOpen came out for vim, delivering vim’s One Missing Feature, there’s really no reason to use TextMate over vim. With insanely fast window spitting, buffer searching, and text manipulation, you’ll save yourself thousands of keystrokes a day by using vim. There are good dotfiles that make it look just like TextMate anyway.

Corollary: Use that editor everywhere. Now that you know vi, type set -o vi on your bash command line. Now use vi to edit your command line. Instantaneous productivity boost of about 10x. If you’re an Eclipse junky, use the Vi plugin for Eclipse.

If you learn one thing in vi: learn to move around using the home row keys, skip words using w, b and change commands such as cw (change word), or ctA (change from current position until the next occurrence of A). This becomes second nature because you look ahead as you type the command to achieve efficiency. There are plenty of tutorials, use google or the built in vi help system.

5. Learn regular expressions. There is no excuse not to know at least the basics. You don’t have to be a regex guru, just be functional. It probably takes a lifetime of meditation to achieve true regex enlightenment. But spending an hour a day trying to use regexes will take you 80% of the way. Read the perlre manpages, that’s where I got my start. Learn to use regexes in your editor to search, on your command line for quick one off scripts, in your programs to do text manipulation.

None of these things are hard, they just take practice and dedication to become true habits. The most important way to turn them into habits is to establish a routine that forces you to apply one or more of these principles and ideas every day.

30 Comments

Posted by
Yan
4 October 2006 @ 6am

Since I wrote this post, I’ve realized TextMate supports emacs-style key movement (Ctrl-N,P,F,B,A,E), so it’s not half bad. Still can’t do something like 5w in vi…


Posted by
trans
4 October 2006 @ 11am

I can’t tell you how much time I’ve spent trying to use vi. But there a few things that continually hold me back.

1) The simplest thing turns into a complex key sequence. That’s fine, IF YOU ALREADY KNOW THE KEYS TO USE. Instead I find myself spending more time looking up how to do something then actually doing it. And more often I just do it the hard way cause I don’t want to stop what I’m doing at the moment.

2) It wouldn’t be so bad if there was some sort of real-time visual indication of what key-presses are going to do. Without that, it’s all memorization. I think it takes me 10 times longer to memorize things than most people. So you can imagine how fun that is for me.

3) Just about every other editing environment uses the ctrl sequences standardized by Microsoft. This textarea I’m filling out right now for instance. Switching “gears” between this and the modal vi drives me crazy. I’d say half the time I use vi I forget to switch to insert mode, or I accidentally toggle to replace mode and start typing away before I notice the mess I’ve made. So I spend way to much time undoing rather than doing.

I wish it were otherwise. I certainly see the power in vi’s capabilities. But usage is so esoteric that only someone who reveals in such thing could really love it. I imagine that true for emacs as well.


Posted by
Doug
4 October 2006 @ 2pm

I think you need a text editor that can do multi-file search, as in most IDEs. I like JEdit. I agree that using regular expressions helps you find things easier.
That’s another good reason to learn Ruby, with its builtin regex literals (like Perl, unlike Python).
Also, listening to music helps me focus and work faster.


Posted by
yan
4 October 2006 @ 2pm

@trans

First of all even MS editors have plugins..I just googled Visual Studio vi plugin. Second, why are you spending most of your time using MS editors? Is it a job requirement? If not, I would urge you to actually invest time in vi/emacs. Yes, it’s hard at first and vi doesn’t mesh with your brain at first if you’re used to modeless editing. However it quickly becomes second nature. Go through the vi tutorial included with vi (type :help). As far as the simplest thing turning into a multi key sequence: that’s the same in any editor you just don’t notice. For example let’s say I wanted to delete five words, in a standard editor I would probably hold down Alt Shift to select words then hit the forward arrow 5 times to select them, then delete. Total 7 keypresses. In vi: ‘v,5,w,d’ : 4 strokes. Maybe it’s possible in less. The strokes mean ‘visual (select), 5, words, delete’. Or even better in vi you can delete up to the next character so let’s say you see a big capital X right at the place you want to delete up to so you type ‘dtX’ (delete to X). It all starts to make sense and becomes very mnemonic afer a while.

@Doug

I absolutely agree on multi file search. If you’re on a unixy system it’s pretty easy too: find . | xargs grep “My search”. Probably you can plug this into vi or emacs as well. I spend most time working in TextMate now so I love their built in multi file search. I agree about the music although for me it has to be a particular type of music. For me Tool and jazz works best. Anything else can be distracting rather than helpful.


Posted by
Alan
4 October 2006 @ 3pm

Doug:
To delete five words in vi, from the command mode type 5dw, that’s 3 keystrokes total. Or if you don’t want to count how many words you want to delete (if I want to delete 5 words I’d need to count them then look for the 5 key because even though I’m a touch typist I don’t really trust my numbers) just type dw and then use the . to repeat the dw. It’s more keystrokes but just as fast because I can do it by touch and watch the words disappear until I’ve done what I want.
Also, if you’re editing ruby with VIM, make sure to install the ruby-vim gem. Better syntax highlighting, indentation, matching, auto completion, etc. And if you’re doing anything complex at all (multi-file editing), do the tags ctags, exuberant ctags is the one I like best: ctags.sourceforge.net.
Best,
Alan


Posted by
Alan
4 October 2006 @ 3pm

One other thing to help in using vi/vim, it’s critical to learn to use the hjkl keys rather than the arrow keys. So install a game that you need to have movement and would normally use the arrow keys and redefine the hjk and l keys to make the associated movements. A few hours of playing the game will cement the keys in your memory, second nature as Yan calls it. I’m not a big game player, but everything from tetris to hack to a might and magic adventure gets re-defined to use vi keystrokes for movement, because it now feels natural to me.
Best,
Alan


Posted by
trans
4 October 2006 @ 4pm

@yan

I use Kate actually. I meant by MS just that so many editors emulate the ctrl sequences designed by MS back in the DOS days. (ctrl x, ctrl c, shift-arrow etc.)

I have tried again and again to get used to vi, but I just can’t seem to do it. Like I said, probably becuse I have a spotty memory and because vi is not ubiquitiuos, eg. I can’t use vi commands here in the textarea I’m typing in right now for instance. So really it just means knowing both ways of doing things. Also, I’m not quite seeing the wonder of hjkl. You already have to move your left hand all the way up to the esc key to get out of an edit mode. I’m less used to that than moving my right hand down to the arrow keys. And as for deleteling five words. I hold down the delete key until the five words are gone. Or hold down shift and right arrow over them and then hit delete: 1 or 2 keys. Also, you over simplify the sequence with vim a little b/c first you have to hit esc to get out of edit mode before you can do anything of these commands.

Anyway, I don’t mean to be pro for again vi. I’m just saying that I have tried it again and again (even forced myself to use it for days on end) and have never found it anything but painful. What bugs me though is hearing people constantly telling other they should be using a “real” editor like vi.


Posted by
yan
4 October 2006 @ 4pm

The secret of the escape key is that vi was designed when the esc key was where the tab is now mostly. But the real key is that you can remap the esc to anything else. But without even remapping, Ctrl [ is equivalent to escape. So if you have your control remapped with capslock (which anyone wanting to avoid RSI should do), it makes it really easy to escape. You just use your two pinkies on the caps lock and the [ key.

My whole point about vi/emacs was that for a programmer, the editor is where they spend most of their time. With the amount of typing we do, you better be trying to conserve on every keystroke. RSI is a real danger. So it\'s not just nice to have a good editor that saves you on typing, it\'s actually beneficial for your health. Not to mention it lets you get your job done quicker. Like with all powerful tools there is a learning curve and no one can learn vi overnight. I\'ve been using vi for about 5 or 6 years now and I probably pale in comparison to \'real\' vi users. I really just know the super basic commands that help me move and change text while conserving keystrokes. I rarely use things like buffers, macros, and all the other power features...

Probably about 20 minutes in a tutorial will get you to 80% of what you need to learn. That is: move h,j,k,l. Word moving: w,b. Delete and change text: d,c. Visual select: v/V. Undo: u. Repeat command using a dot, do multiples of any command by typing a number beforehand. Move to text using \'t[Character]\’ and combine it with change and delete commands. Also search (/) and moving through search results: n/N. If you can get these things down and practice them you\’ll already be a boatload more efficient than a regular texteditor.


Posted by
Jason
4 October 2006 @ 4pm

You really harp on keyboard/mouse switching.

One thing I like about laptops is the track pad is aways under my thumbs, so it’s quick to use for scrolling, etc.

VI key commands are based on old TECO editors. That’s why they’re obtuse.


Posted by
Brandon
4 October 2006 @ 9pm

I use Kate actually. I meant by MS just that so many editors emulate the ctrl sequences designed by MS back in the DOS days. (ctrl x, ctrl c, shift-arrow etc.)

@trans: You’re kidding, right!? M$ stole those from Apple. (Except Apple used the Command key instead of the ctrl key. This, of course, makes more sense, since these sequences are used to issue a command to the program. It’s also easier to use your thumb for the modifier key than to use your pinky, which PCs make you do.)

BTW, I totally agree with you about vi/vim. I’ve tried them several times and can’t get my brain around them. No matter how much my UNIX admin/DBA coworker hassles and mocks me about it.

TextMate is the only editor I’ve *loved* using. I’ve tried UltraEdit, JEdit, vi, vim, emacs, TextPlus, Crimson Editor, Visual SlickEdit, etc. etc. It REALLY sucks to have to work on a PC for my day job, and not be able to use a good editor like TextMate, or even a half-decent one like BBEdit. It’s so ironic that the Mac has always had the best editors, even before TextMate.

I’ll have to try Kate…


Posted by
Chris Adams
5 October 2006 @ 1am

http://www.friday.com/bbum/2006/03/13/useful-subversion-shell-aliases/ has some subversion-related aliases which have saved me a comical amount of time.

Two minor notes:
- for simple multi-file search grep -r is a handy time-saver over find constructs
- perl and ruby have an absolutely fantastic set of command-line options for running arbitrary code fragments in various ways: -e executes the next parameter as code, -p assumes a while loop over stdin with an implied print after your code runs, and -i will replace the contents of input files with output of your code, optionally backing up the original file:

perl -p -i.bak -e ‘s/OldName/NewName/’ *.c
perl -MMIME::Base64 -e ‘print decode_base64(“eW91IGFyZSBhIGdlZWssIHlvdSBrbm93Li4u”);’

This can lead to [ab]useful constructs like this snippet which resolves IP addresses:
perl -MSocket -p -e “s/([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})/gethostbyaddr(inet_aton(\$1), AF_INET)/e”

(admittedly, I don’t use this one – I have a similar version saved as ~/bin/inline-resolver which adds a few formatting options)


Posted by
Michael C
5 October 2006 @ 2am

The “startup time” charge is one often levied against emacs. The secret? DON’T SHUT IT DOWN.

vi[m] is a great editor; elegant as hell interface, beautiful execution. Emacs also edits, but if that’s all you use it for, it’s like buying a house so you can pull a window down when you’re hot.


Posted by
Bheeshmar
5 October 2006 @ 3am

After I learned about insert-mode completion in Vim, I couldn’t use another editor: In insert mode, type a few characters and hit Ctrl-N, and the next word in the file, included files, or open buffers that matches the letters you typed is substituted, Ctrl-N again substitutes with the next match, Ctrl-P goes back. Look in :help ins-completion.

It’s like Intellisense, but more general. It doesn’t resolve methods like intellisense however. MS Dev Studio editor uses Ctrl-Space for a similar feature. Emacs uses Alt-/ I think.

Completion is an incredible accelerator.


Posted by
Fabio Aquotte
5 October 2006 @ 4am

@trans

You should give Cream for Vim a try: http://cream.sourceforge.net/home.html . It is a configuration that makes Vim behave like “modern” editors (modeless, Ctrl-C Ctrl-V, etc) while keeping its power (syntax highlighting, auto indenting, etc).

@Bheeshmar

In Vim 7 there is also omni-completion, which works like intellisense: http://vimdoc.sourceforge.net/htmldoc/version7.html#new-omni-completion . It’s incredibly handy.


Posted by
yan
5 October 2006 @ 4am

@Chris

Awesome svn tips, thanks!


Posted by
Steve
5 October 2006 @ 7am

Yet another VI-related tip: you can use VI bindings in Emacs using its built-in and very complete VI emulation. Just type “M-x viper-mode”. Selecting the ‘wizard’ level means that any non-conflicting keys from the regular emacs keymap will work too. In over 6 years of doing this I have never learned the emacs keystrokes for most editing commands — it’s a great way to have a well-supported editor/IDE that works the same as quick console VI sessions.


Posted by
Quentin Gallet-Gilles
5 October 2006 @ 3pm

Fewer keystrokes, less mouse usage and eye search… I’m beginning to think this is not really about productivity boosts but more about fighting RSI (and in the end, it may indeed give you productivity boost).

Following that spirit, I think one of the most important thing to do to prevent (or cure) RSI is throwing away your QWERTY keyboard and using a Dvorak one instead. The switching process can be done faster than binding hundreds of vi commands in your head, so no excuse for not trying it :)

More info about the Dvorak is available here : http://www.mwbrooks.com/dvorak/


Posted by
yan
5 October 2006 @ 4pm

Dunno, vi binding is mostly mnemonic, while dvorak binding means remapping a whole bunch of keys in a non-predictable fashion…

I also use one of those Kinesis Contoured keyboard which did wonders for my wrists which were starting to hurt. I also find out of laptops, Apple keyboards (at least on the iBook) are not as bad as thinkpads or other pc notebook. Something about the keyboard seems softer and easier to actuate.


Posted by
John
5 October 2006 @ 8pm

The thing I’ve always hated about vim (though I always use it often) is that the most frequent thing I do takes way too much effort. If I’m typing along and want to save the file and keep typing, I have to type ESC, Shift, ;, w, Enter, i. That’s six keystrokes, and for one of them (ESC) I have to pick up my hand and move my whole forearm to reach it. CTRL-S takes 1/3 of the keystrokes, and even Emacs’ CTRL-X-S takes 1/2. Since I do this every minute or two when I’m editing a file, it’s super annoying. Then you have the related and more general problem that ESC is a commonly used key and it’s far away from the home keys. Vi might have been developed for the ADM3A keyboard layout, but it’s been a long time since almost any programmer has typed on one. And please forgive me if I don’t see replacing one keystroke with two as you suggest as a good solution to the problem.


Posted by
yan
5 October 2006 @ 8pm

I use a kinesis keyboard so actually Ctr [ is pretty comfortable to type because it involves a thumb and a ring finger and you don’t really leave the homerow position. Another good subsitute is Ctrl J if you have Ctrl mapped in the Caps Lock position because it involves all homerow. I’ve actually mapped Ctrl J to completion in TextMate because TM’s use of Esc for completion is a terrible choice, just like vi.

I do agree though that saving the file is annoying. of course you can remap a shortcut to do that if you want…but I agree that it’s a poorly thought out procedure in vi.


Posted by
Pete
6 October 2006 @ 3am

@John:

You can remap things in Vim (as yan suggested). For example, one partial “solution”(?) to your saving issue that I just tried out is the following:

:imap :w!a

Then, in insert mode at least, a quick control-I will save.

If you’re using gvim, you should be able to replace C-I with C-S, which will give you exactly what you wanted (in insert mode). The only reason you can’t use control-S on a Unix terminal is because control-S by default maps to “stop”, which freezes terminal input (this can probably be disabled, but I know not how).

Try :help map for more information. And there is almost certainly a better solution than the above, something that also works in command mode. The above was just a quick hack. :)


Posted by
Pete
6 October 2006 @ 3am

Crap. Er, let’s try that again….

:imap <C-I> <Esc> :w!<CR>a

Bloody HTML. :)


Posted by
links for 2006-10-13
13 October 2006 @ 1am

[...] Five ways to get insane productivity boosts (tags: gtd code arbeit) [...]


Posted by
wtpuxtldif
24 May 2007 @ 4pm


Posted by
Jeanie Beasley
12 November 2008 @ 10pm

p3ijlkfbj0a1zni1


[...] this post? Here are some more you might enjoy: Five ways to get insane productivity boosts Colorful ruby tests and [...]


[...] the principles of insane productivity I’ve blogged about earlier, I am releasing my dotfile repository, containing customizations [...]


Posted by
Code4pay
31 December 2011 @ 4pm

Instead of Grep for multifile search you should be using ack, it is like grep but designed for source files. http://betterthangrep.com/


[...] Maps Does Nothing In ChromeBottlenecks in Programmer Productivity Yan Pritzker recently posted “5 ways to get insane productivity boosts for coders” which provides some good tips on how to improve your usage of tools when doing technical work. [...]


[...] 5 ways to get insane productivity boosts for coders http://yanpritzker.com/2006/10/03/five-ways-to-get-insane-productivity-boosts/ [...]


Leave a Comment

To post code, use <code></code> tag around your code