Stack OverflowWhat tricks can be used to type and edit code faster?
[+100] [61] Thomas
[2010-05-09 13:48:11]
[ development-environment editing ]

As Jeff Atwood noted, we are typists first, programmers second [1]. Fast typing and editing may not be essential to be a good programmer, but it certainly helps. I noticed that I consciously and subconsciously use various tricks to get my intent across to the computer as fast as possible.

What tricks can be used to type and edit code faster?

I'm hoping to collect a nice list here that we can all learn from, so that we can be ever so slightly more productive. One trick per answer please!

This is not about typing speed in general. There are other questions [2] about that. It's also not about general answers like "learn your editor's shortcut keys". Think of this topic as micro-optimizations for specific cases. See my own answers for examples of what I mean.

(Are you coming here from TDPE2 [3]? You want to read Toughest Developer Puzzle Ever 2 [4].)

(44) Pretty much all of these tips could be replaced with 'use Vim' - rjh
Part of the reason why I started diving deeper into vim today :) - Thomas
Vim is overrated. How do I replace all X with Y within a selection in Vim? In SciTE or VS, I simply select a block, hit Ctrl+H and do the needful... How do you do this with a column selection in Vim? What about multiple selection? - Agnel Kurian
(3) @Vulcan Eager: The First Rule of Vim, that I learned during the past few days: if you can come up with it, Vim can do it., and I did not test these, so they may not be entirely what you meant, but you get the idea. I have never felt a need for the last two, though -- if you actually use stuff like that on a regular basis, please post an answer to this question and explain :) - Thomas
M-% vim emacs ;) - jk.
Do we really need to type and edit code faster? How much time are these tips really adding up to? I usually think for a bit---type---think for a bit---type. These tips are like telling people to leave the tailgate down on their trucks to save gas. They just add up to a little more than nothing. - kirk.burleson
[+80] [2010-05-09 15:28:17] ADB

The single most useful (and potentially obvious, but who know?) tip that must have saved me hundred of hours over my programing time:

Use whole word caret movement shortcuts (control-left arrow/control-right arrow) to rapidly go the line location you are seeking. Use them in conjunction with shift for quick selecting of a couple of words.

Corollary: use beginning of line/end of line shortcuts.

Example: let's say you have the following line of code

ClassA toto = new ClassA("A nice string", 10, -300, MAX_VALUE );

Your caret is on the keyword 'new' and you want to change -300 to -299. What is the fastest way, assuming both hands are on the keyboard?

  • Moving hand from keyboard to mouse and go to location, move back to keyboard then edit? No.
  • Press the right arrow ~30 times? No, not even close
  • Press control-right seven times, control-backspace once then type 299? I wouldn't fault anyone for doing that, it is the right idea
  • Press end, control-left twice, control-delete then type 299. Bingo

(45) In Vim: f-1<ctrl-A>. f- goes to the next "-" character. 1<Ctrl-A> increments the number under the cursor by one. That is four keystrokes. - Dave Kirby
Great answer. I use this all the time myself. So annoying that many Windows applications still don't grok Ctrl+Backspace. - Thomas
My personal variant for such a case: works on my usual editor gedit: Ctrl-F, 3, 0, 0, Enter, 2, 9, 9. In this exact case you get me by one key press, but mine also work if the cursor is a few lines before, or current line is longer. - kriss
(18) Correction - in Vim you can do it in three keystrokes, since <ctrl-A> defaults to incrementing by one - f-<ctrl-A>. - Dave Kirby
(3) @Thomas: It's even more annoying that many applications still don't grok Vi-style editing! - slacker
(5) @slacker: The power of Vim keeps surprising me. Maybe I should learn it beyond :qa!... ;) - Thomas
(5) I 'm in the :qa! camp as well regarding Vim. I think that all this "Vim does this in N keystrokes" stuff is not relevant. All kinds of software does all kinds of things, e.g. with ReSharper I can safely rename a class that's referenced in 1000 files with (3 + as many edits I make) keystrokes. What does that say? It would be better to just provide advice that can be used by everyone regardless of their specific choice of IDE or editor. - Jon
(14) Vim shortcuts are so unintuitive. Whatever fraction of time you gain by pressing fewer keys is massively wasted by remembering the shortcut (sure, f=find, but s=search and f could be other things), deciding that the quickest way to get to where you want is to do a find for the - character, then finding and typing the keys on the keyboard. In the meantime, I've used the Ctrl key at the far corner of the keyboard and the arrow keys that are in their own block, to press twice as many keys without even looking at the keyboard in a quarter of the time. /rant - DisgruntledGoat
I agree with Jon here, program-specific shortcuts are not relevant here. - Arsenal
(1) This can be done even faster in Visual Studio. Press Ctrl+I for incremental search and press 3 :) - Marek
(1) Of course, how many keystrokes something takes in vim is irrelevant, since vim is a text editor, not an IDE - it contains lexical abilities (regex), but no parser, so it cannot even do something as simple as (safely) renaming a variable... - BlueRaja - Danny Pflughoeft
(1) @DisgruntedGoat: Vim commands are a language. There's more than one way to express yourself; it takes time to learn and perfect; but once mastered, you can become very eloquent and express things in a fraction of the words that a less skilled speaker would use. Your use of Ctrl/arrow keys is a language in itself - one that you've become very familiar with - so it's no surprise that you'd have trouble learning another one. - rjh
(2) @BlueRaja: coming from a UNIX background I believe a program should specialise in what it is good at and try not to do everything. I'd be quite happy to type (productively) with vim and refactor using a separate tool. It's asking too much for vim to implement refactoring and deep code understanding for every language, or for your typical IDE (Visual Studio etc.) to have the text manipulation power of vim or emacs. - rjh
this is exactly how i do. Many people don't know ctrl+arrow usage, and dont have the common sense to use home, end. You can extend this for selecting text. For example, if you want to select everything excluding the last word, home, shift+end, shift+ctrl+left arrow. - rao
(1) @rjh: coming from a UNIX background I believe a program should specialise in what it is good at and try not to do everything. - That is an argument against using vim to program. Use a tool specialized for that language - don't try to hammer a nail using a swiss army knife. - BlueRaja - Danny Pflughoeft
@BlueRaja: The question wasn't specifically about IDEs so VIM is a valid answer - Otto Allmendinger
Unless I was working with ridiculously long lines (hardly ever the case), I just press and hold Ctrl+Right, and release when I get to the desired position. With keyboard properties set to shortest repeat delay and fastest repeat rate, you're moving at about 30 words per second. I find this faster/more practical than having to figure out the "shortest path" mentally every time. - Daniel Liuzzi
@BlueRaja: Vim is for editing text. Program sources are text. A separate tool for refactoring is fine, as you shouldn't have to do it a lot anyways (and half the time no tool can automate it for you)... @Daniel: It's still 10x faster to use the vim command than to ctrl+(left|right) 10 times, and the mental calculation takes about a millisecond. - L̲̳o̲̳̳n̲̳̳g̲̳̳p̲̳o̲̳̳k̲̳̳e̲̳̳
For vim: what happened to '/3' followed by Enter? What is the need to remember f-<Control A> when 'search for next appearance of 3' is right there? - Adriano Varoli Piazza
[+53] [2010-05-09 13:48:32] Thomas

When pasting with the mouse, work backwards through the line.

Suppose you have a line like this:

foo(x, y, z);

and you want it to look like this:

foo(bar.x, bar.y, bar.z);

If you paste the bar. with the mouse (either middle-click on *nix, or click and Ctrl + V), it's faster to start at the back. That way, the next location where you want to paste does not move, so you can go there faster.

This was accidentally edited to be identical to a different answer; I rolled it back. Don't know which answer the upvoters saw... - Thomas
(3) This is a great trick for applying edits to any sort of work from hardcopy. Work backwards and your line numbers / column positions (for soft wrap) won't change! - Matt B.
(2) After pasting, the cursor would be after the dot in "bar.", which means you'd need to move your cursor more spaces to the left to paste the next "bar." - AngryWhenHungry
is it in poor taste to add vim alternatives to these? from the start of the line: "f x i bar. [escape] f y . f z ." find x insert 'bar.', find y do the last thing again, find z do the last thing again - Andrew Khosravian
@AngryWhenHungry exactly. That's why when pasting with the mouse you should go backwards, but when using the keyboard you should go forwards. - asmeurer
[+47] [2010-05-09 15:12:15] Conrad Albrecht

For all bracketed constructs -- (), [], {}, "", /**/, etc -- type the bracketing first and then fill it in. In particular, for /**/, type this on the number pad.

This also helps avoid confusing compilation errors from forgetting the end bracket.

(6) My editor does this by default. - JUST MY correct OPINION
(33) /* */ on the numpad... why didn't I think of that? That's exactly the kind of thing that I was hoping for :) - Thomas
(3) I'm not sure whether typing the brackets first is actually faster -- you have to move your hand off the home row and to the left arrow key to fill them in. However, the time savings of not forgetting brackets are probably worth it. - Thomas
@thomas: use neo <>;, so you do not have to move your hands off the homerow neither for brackets nor navigation - knittl
[+31] [2010-05-09 15:41:27] Dave Kirby

Learn Vim. It is available on virtually every platform, and you can do things from the keyboard that are unimaginable in most other editors. The learning curve is steep so expect your productivity to plummet for a couple of weeks, then soar as your muscle memory learns the Vim way of doing things.

See my comment to AD's answer [1] to this question for an example.


(3) Would upvote 10,000 times. Every other answer, except (grudgingly), the one about Emacs, is some workaround for a sub-par editor. - Derrick Turk
(6) steep learning curve is not worth it... - Tim
(10) @Tim: For something you're going to do for the next forty years or so, it makes little sense to complain about a steep learning curve. If it takes you forty hours to become reasonably proficient with vim, and it saves you 0.1% of your working time for your next forty years, you're coming out ahead. - David Thornley
(9) I don't know anyone who can be as productive in vim within 40 hours as they can be in something like visual studio right from the start... My choice of IDE is also chosen for other capabilities - not just super-fancy ctrl-alt/keyboard tricks. - Tim
@Tim: With fancy IDEs with frameworks that do the typing jobs for you, your productivity will be boosted by automated code generation. However, the question here is "to type and edit code faster". - shinkou
(1) @Tim wins the award for lazy and being one of the many developers I meet who keep doing things the slow way for the rest of his life. Let me guess, touch typing is too steep a learning curve, too? Hunt-and-peck programmers are the biggest joke ever. - PP.
@PP I have more important things to learn than an esoteric, outdated editor. - Tim
(1) @Tim outdated how? And esoteric how? [Citation needed] - Adriano Varoli Piazza
(1) "The learning curve is steep" is all one needs to hear. - Tim
Oh, I suppose becoming proficient in VS or Eclipse is a piece of cake, then. Yea, learning to set up a project, compile it, etc, easy peasy. - Adriano Varoli Piazza
[+29] [2010-05-09 16:23:19] Aaronaught

Learn and get comfortable with the beginning/end-of-line and beginning/end-of-file shortcut keys.

By environment, those are:

Windows (all)  │  Home    │  End     │  Ctrl+Home  │  Ctrl+End
Linux (all)    │  Home    │  End     │  Ctrl+Home  │  Ctrl+End
Mac (all)      │  ⌘←      │  ⌘→      │  ⌘↑         │  ⌘↓
Emacs          │  Ctrl+A  │  Ctrl+E  │  Meta+<     │  Meta+>
Vim            │  0       │  $       │  gg         │  G

You can quickly highlight an entire line of code by pressing the EOL key, then holding ⇧ and pressing the BOL key (that's End, Shift+Home on Windows) and then use the up or down arrows to highlight multiple lines.

(2) Note that this is on a Windows machine, not on a Mac. On a Mac, Home and End scroll to the beginning and end, respectively, of a file without moving the cursor. To move to the beginning and end of a line, use ⌘← and ⌘→, respectively. Hold down ⇧ to select as well (so to select a whole line, you can hit ⌘→ and then ⌘⇧←). To go to the beginning and end of a file, use ⌘↑ and ⌘↓, respectively. (The ⌘ and ⇧ symbols denote, respectively, the command and shift keys.) - Antal S-Z
I'd even go further with using Emacs. Home and End buttons are too far, since you have to move your hands from the home row. Ctrl-a and Ctrl-e are closer and faster. Also, using Ctrl-b and Ctrl-f to move the cursor left and right is faster than to move your hand to the arrow keys. - Kimmo Puputti
Eek, I guess I should have qualified this as being Windows/Visual Studio centric. I'll try and edit this to include all platforms/environments. Being Community Wiki, you guys can feel free to edit too! (just keep it readable and organized) - Aaronaught
BOF and EOF are Meta+< and Meta+> in Emacs, couldn't get them appear in the post... - Kimmo Puputti
I use ^ for Vim's BOL. Had no idea that 0 worked too. - Auguste
(3) @Auguste: 0 in Vim goes to the BOL, and ^ goes to the first non-whitespace character on the line. ^ can therefore move you forward. Eclipse, and I believe lots of other IDEs, has the Home button first go to the first non-whitespace character, and if the cursor is in that place and Home is pressed, it goes to the BOL. - Heikki Naski
Apparently there's some browser wonkiness with the formatting on the Mac line - I'm not sure what the deal is, but I'm pretty sure the current version is correct on most browsers, so please leave it... - Aaronaught
This alone is the reason I hate coding on a Mac. Every time I hit home only to lose my place in the document and end up at the beginning of the file, I want to thrash my keyboard into a million bits and pieces - Chris
I've never used Vim, but if all the shortcuts are as unintuitive as I see above, it seems like there would be a lot of time wasted in remembering what they are if I take a break from coding for a couple weeks. - Barodapride
[+27] [2010-05-09 13:49:17] Thomas

Keep line endings in mind while cutting and pasting.

Treat newlines as normal characters when cutting and pasting. When cutting and pasting one or more full lines, include the final newline, so you don't have to remove it in one place and re-add it in another.

(3) So many programmers ignore this one. I have always done it, and I can't seem to figure out why it's not more common. - MJB
(1) For me, pasting several lines onto the end of an existing line just seems wrong, I always like to insert a new line to paste code onto. - MiffTheFox
Also, I want to add that you should also look out for tabs, unless you're using an editor like Visual Studio that reformats code on pasting. - MiffTheFox
If you're using vim you can type dd to take out entire lines, including the newline. Or you can use V to enter "Visual Line" mode which lets you select only entire lines. - R. Martinho Fernandes
The one good thing about most MS software is that you can click in the margin and select the whole line, including the line ending. I've yet to find an editor on Linux that does this, so I end up selecting backwards to get the newline before. - DisgruntledGoat
@DisgruntledGoat: Shift+V in vim goes to visual line mode. Although for single lines, you'd normally use dd or yy to cut or copy the line, respectively. (Yay, I'm learning vim!) - Thomas
@Thomas: oh, and vim lets you select a line with a single mouse click? Thought not. Sure, in any editor you can come up with a combination of keys to select a line. Holding Shift then pressing End and the right arrow will do the same thing. If I'm not mistaken, the question is about saving time. - DisgruntledGoat
+1. I cringe when I see people mess up code indentation for not moving the caret to the beginning of the line before cutting/pasting multiple lines. - Daniel Liuzzi
[+16] [2010-05-09 14:52:58] ing0

Using IntelliSense [1] or the equivalent always helps speed up coding.


(1) It's a good thing the use of Intellisense is default (we hope). - IAbstract
Maybe he means features like Snippets, which not everyone uses. - Mathias
I mean more along the lines to speed up coding. For example in VS when you write "Cons" if you press Alt + Right it will complete to "Console" or if you write "Console.Wri" then Intellisense will pop up and you can press space to complete with what it thinks you want to write. If you get used to this you can write lots of code pretty fast. - ing0
(1) ctrl+space is easier to hit I think than alt+right - BlueRaja - Danny Pflughoeft
I think it's just what I'm used to! I develop both .NET and iPhone so sometimes it's Alt + Right and sometimes it's just tab! :) - ing0
[+15] [2010-05-09 13:49:00] Thomas

When one hand is on the mouse, use Enter on the numpad.

When my left hand is on the left side of the keyboard, and my right hand is on the mouse, I sometimes hit numpad Enter with the thumb of my right hand. This only works if you use the mouse with your right hand and have a relatively low keyboard (mine's a Logitech UltraX).

I don't really see the potential. As a typist first, this doesn't seem ideal - unless I'm not using my mouse the correct way. - IAbstract
@dboarman: What do you do with your thumb when you're using the mouse? Not much. You can very easily hammer on the numpad-enter with it. - Rubys
(3) I do my work on laptops mostly. This doesn't work well. ;) - JUST MY correct OPINION
@dboarman: Sometimes the mouse is the fastest way to get your cursor to a remote spot in your code. Actually, this one is so ingrained that I know that I use it, but I don't know when. I'll keep an eye out for it :) - Thomas
@Thomas: ...unless you use Vim :). There's always a few strokes combo which gets your cursor where you want it. - slacker
@slacker: Stop rubbing it in, dammit! Now I've closed my trusty old Kate editor and launched a terminal with vim! I managed to learn dvorak, so how hard can an editor be? - Thomas
I use a trackball not a mouse, and I keep my trackball positioned so I can do this. Not as useful with a mouse I would think. - drawnonward
How much time are you saving? - kirk.burleson
[+14] [2010-05-09 14:46:33] robsn

Use Das Keyboard Ultimate [1].

It will help you look more at your screen and less at your keyboard.

Keyboard with blank keys


(8) I haven't looked at my keyboard in ages. Getting an unlabelled one just seems a bit ... quirky. - JUST MY correct OPINION
After getting one I realized I had looked more on it than I thouht I had. Especially when it came to special chars or shortcuts. But true. If you're already an advanced typer you probably don't profit too much except for the great look and feel. - robsn
That is a horrible classic-keys keyboard. - Lohoris
(2) Or, just peel the stickers off your current keyboard. - DisgruntledGoat
(4) Mine got unlabeled on the sweet spots by heavy use....still a few years left to unlabel the rest of it. - Marek
(6) This is the keyboard equivalent of training wheels on a bike. Just ride the damn thing. - rjh
(1) This is the greatest keyboard in the world. If you do not have one you will not understand. That is all. - Sam Pearson
(5) I don't really look at my keyboard anyway - why would I pay 100 dollars for something that removes functionality? Sometimes I don't remember which / or * key is which on the numpad. A quick look is worth it then. - Andrei Krotkov
I don't think it was meant to be serious. Funny though :) - PP.
It's also great fun to simply exchange the locations of keys. - Christian
Also worth to mention that, on the occasions you do need to look at the keyboard, you're hosed. Perhaps your wife needs to type a quick letter? Perhaps we don't have multiple machines lying around the house? Perhaps you can't type from memory a long password? - Adriano Varoli Piazza
How many people have to count the function keys to find the correct one? - kirk.burleson
[+13] [2010-05-09 15:28:42] mikerobi

I spend significantly more time tracing, testing, debugging, reading, and thinking about my code than I spend typing it. I could increase my typing speed 100x and don't think I would get a significant boost in productivity.

(13) Perhaps, but that's not the point of this discussion :) - Thomas
If you're prototyping in a console/REPL/similar environment, being able to quickly express yourself becomes less of a barrier to thinking (and trying) things through. Again, sometimes you need to adjust five different places in code somewhat atomically. The faster you can get through them, the less likely you'll forget a step by the time you get through them. - steamer25
(11) The funny aspect is that most slow typing programmers say that typing speed does not matter and almost no fast typing programmer would agree with this. - Marek
(8) It's not so much about the actual time spend typing but about not having your flow of thoughts interrupted. - Christian
(4) Typing skill also decreases your chances of making mistakes. You would probably spend less time tracing, testing, debugging and reading the code if there wouldn't be those typos in variable names. And most programmers don't just think about a non-trivial problem and code it in one go, without experimenting, changing, refactoring or rolling back the code several times. And of course, there's documentation, emails and instant messages to be written which can all contain code. - Heikki Naski
@Marek, I think that largely depends on how fast or how slow, most programmers probably fall in the middle. - mikerobi
(1) @Heikki Nask, real programmers don't write documentation ;) - mikerobi
@mikerobi, yeah, but it also takes a lot more editing skill to write assembly blindfolded in a blizzard. Nice of you to help me make the point about typos, by the way. - Heikki Naski
(16) I disagree with this. Have you ever watched a programmer who does everything the slow way? It really is ridiculously slow. Furthermore, it's so slow that you have to slow your mind down so you don't get to far ahead of what you're doing. - tster
@Christian: Exactly - But the faster you think, the faster you have to expel the buffered thoughts. Otherwise you'll fill up and will start losing chunks from the mindstream. - tsilb
(3) Fast typing/editing is needed to stay in sync with your brain developing the code. Or as the Mylyn 3.0 tagline says: "Code at the Speed of Thought" - Bananeweizen
@Heikki Naski, your point is irrelevant, typing speed and typing accuracy are not the same thing. - mikerobi
@Marek,at least Douglas Crockford agrees with me, he has echoed my sentiments when commenting the ++ operator. - mikerobi
[+12] [2010-05-10 05:32:13] serg

The single piece of software that saves me a lot of time is the multi clipboard manager (like ClipX [1]). It allows you to copy several parts of a source file at once without switching back and forth between files, and furthermore it keeps the clipboard history so, if you accidentally overwrote the latest clipboard entry, you can easily recover it.


+1 for multi clipboard manager. On OSX I use Jumpcut. - Lohoris
FYI, current versions of Visual Studio have this built in. - AviD
(5) In other words, a poor man's Vim named registers? - slacker
I use Ditto, almost perfect - Raveren
I like Clipmate on Windows. - RandomEngy
(2) @slacker its better than vims because it works on and across every program. - ino
ClipMenu is a good version for the Mac. - asmeurer
[+12] [2010-05-10 20:39:21] steamer25

Learn to use regular expressions in your editor/IDE.

For example, earlier today, I was annoyed by a file that had excess whitespace at the end of the majority of its lines. Replace \s+$ with an empty string took care of it.

(2) I have been just amazed sometimes at the sheer amount of work I've saved by using a regular expression search-and-replace. It is really one of the most amazing things computing has to offer - and I consider myself adept at regexps. Sometimes I set up an interactive search and replace and find myself deliriously overjoyed at the transformations occurring in front of my eyes. - PP.
[+11] [2010-05-09 13:48:46] Thomas

When pasting with the keyboard, work forwards through the line.

Suppose you have a line like this:

foo(x, y, z);

and you want it to look like this:

foo(bar.x, bar.y, bar.z);

If you paste the bar. with the keyboard, then navigate with the arrow keys to the next location, it's faster to start at the front. For example:

foo(bar.x, y, z);
foo(bar.x, bar.y, z);  // and so forth

Otherwise, you have the newly pasted bar. to navigate over..

Meta link discussing duplicate creation:… - Michael Petrotta
Yeah, it was me. The two answers looked so much alike (of course, I failed to read the titles) I thought I was crazy. - IAbstract
[+11] [2010-06-06 01:30:41] Daniel Liuzzi

Block Selection

alt text





This has saved me tons of time when making repetitive changes in long blocks of code (providing it's properly indented). It works with Visual Studio as well as with Notepad++.

Image source and more complete explanation [1].


(1) Emacs also offers this functionality in cua-mode: press ctrl-Enter to activate. - PP.
(2) For completeness: in vim, visual block mode is activated with Ctrl+V. Replacing (with 'c') replaces all lines in the block, which is tremendously useful. - Thomas
Vim does this with ctrl+v - demil133
[+8] [2010-05-09 21:54:38] David Relihan

My favourite is the shortcut to jump to the closing curly brace: Ctrl + ] in Visual Studio [1] and Ctrl + Shift + P in Eclipse [2]. I use this a lot.


...and ]} in Vim. - slacker
[+7] [2010-05-10 05:21:58] serg

Switching to overwrite(replace) mode by pressing Insert button can speed things up sometimes quite a bit when you need to make replacements without changing a word length (usually in a vertical block of text). For example if you need to increase indexes by 1 here:

array[0] = ...
array[1] = ...
array[2] = ...
array[3] = ...

Switching to overwrite mode allows you to navigate to required position in every line by using down and left arrow keys, which is much faster than down and backspace as they are far apart. And if your editor remembers cursor position, then all you need is use a down key after each replacement.

(9) Now somebody's going to say how you can type 4 Ctrl+A j in vim, or something like that... :) - Thomas
(1) Simple bit of advice that I had honestly never thought of. The number of times I have to edit a text file to change a single value is crazy, and this would save me so much time. (Obviously, writing a tool to do the replacements for me would save more time, but you know how it is) :) - ZombieSheep
(1) In Vim, I'd do it with <C-a>j.j.j. - Heikki Naski
(2) Watch out. If there's both more than 9 values, this trick will sometimes overwrite the ] on the 10th row when your fingers continue flying on auto. - Andrei Krotkov
Wow, a practical use of Insert-mode! - eisbaw
[+6] [2010-05-09 15:04:12] EvilTeach

Set up keyboard macros for your commonly used patterns.

In Visual Studio I use Ctrl + ALT as a base.

Ctrl + ALT + i - if () {} else {}
Ctrl + ALT + f - for (;;) {}

I omitted the line breaks above.

(2) Or just type for then press TAB twice. - Callum Rogers
Nice Edit Peter. - EvilTeach
(3) Unless I'm reading something wrong, I feel like this would actually waste time for me. The time I'd spend navigating to between the parentheses and brackets would pretty much equal the amount of time it takes me to type if () {} else {} around whatever code goes in there. Of course, that might just be me. - Maulrus
[+6] [2010-05-09 15:35:51] kriss

Avoid mouse, learn shortcuts. What can be done with mouse usually can be done ten times faster using keyboard if you know your shortcuts.

Also think more and type less, and use an advanced editor that you know well.

Two exemples of precious features:

  • smart use of regex or of macros avoided me hours of typing (a standard typist may find them too complex, but for programmers it should be a piece of cake).
  • use autocompletion features of your editor (also avoid typo for keywords).

+1 for noting that autocompletion is great for checking typos. I don't personally think that it saves huge amounts of time since if you type ~70 wpm you will probably save only a couple of seconds when autocompleting a long symbol name, and sometimes you lose time looking at the popup and selecting the correct symbol. The typo prevention is why I use automatic completions, and it's more comfortable too. - Heikki Naski
If you type enough that there's no ambiguity, it's very easy to fall into the pattern of [CTRL]+[SPACE], [ENTER]. Saves a few keystrokes, especially in languages such as Java, where every class is ClassWayTooLongOfANameOne. ;) - Andrei Krotkov
[+5] [2010-05-09 15:53:05] Daniel I-S

Navigate backward and forward between the places in code that you're editing.

A lot of time can be wasted scrolling and mouse-wheeling between several physically distant areas in the same project. In Visual Studio, hit Ctrl + - and you will jump back to the last place in the code that you made an edit. Ctrl + Shift + - will jump you forward again.

For bonus points, bind these shortcuts to the back and forward buttons on your mouse. Awesome.

(3) I think this is editor-specific... - Thomas
(1) Oops! Yes, this is Visual Studio specific. But I'll leave it here, since it's still useful, and there's some other editor-specific stuff above. - Daniel I-S
I think it's fine. Navigating to places where edits were made is a concept, and it's good to see an example. For Vim, use '. to go the last change and '' to move back to the place before last jump. - Heikki Naski
[+5] [2010-05-10 20:58:33] Rafał Dowgird

Use incremental search and backward incremental search for navigation. It's like teleporting instead of walking - usually Ctrl + S or Ctrl + R (Emacs bindings) or Ctrl + I in Visual Studio [1] plus two to three keystrokes get you anywhere on the screen. Well, unless you're editing ASCII art or binary memory dumps :)


[+5] [2010-05-11 02:11:10] Richard Hein

The best musicians still practice, and the best typists would in theory, still practice.

Part of building speed and accuracy is simply "slow down and perfect it", which is amoung the biggest hurdle for music students to overcome (according to well know famous musicians/teachers, such as Andreas Segovia). In theory the same principles apply. It should be easier to perfect than an instrument, because typing is not a performance art (unless you are presenting). So when you make any mistake, you should stop and think and feel your whole body. The muscle tension in the fingers, the hands, spinal column position and curvature, etc.... Then focus on the tension and correct, by relaxing and slowly moving through the motions until it's smooth and you are totally relaxed except for the absolute minimal muscle tension required to move the finger to where you want it to go. This builds muscle memory, and you have to unlearn all the bad habits, by slowing down, and eliminating all wasted motion.

[+3] [2010-05-09 15:55:29] Norman Ramsey

Learn to use either hand to type Shift, Meta/Alt, and Ctrl.

(One reason I don't use a Mac is that the Mac requires four modifier keys, and I can't find a reliable keyboard that has all four on each side.)

The standard Apple aluminum keyboard has all 4 modifiers on both sides. - drawnonward
@drawn: tragically, the 17" macbook pro does not. That's one reason it's gathering dust in a closet... - Norman Ramsey
[+3] [2010-05-09 16:57:49] Zaid

It's a shame that the DVORAK keyboard layout [1] hasn't really caught on.

QWERTY was allegedly designed with the intention of capping typing speeds so as to prevent mechanical breakage of the good ol' typewriters.


(1) If I could get a Dvorak, I would take the time to learn it. - IAbstract
I'm using dvorak myself and notice the difference, but I seem to be the exception. See also… - Thomas
(1)… - Pindatjuh
I swapped my keys on this laptop: almost 2 hours trying to type, and its quite easy to learn! - Pindatjuh
(6) Please read or before investing your time in learning Dvorak. - Rafał Dowgird
-1, reading Rafal Dowgird's links pretty much disprove this answer. - Maulrus
I once learned to use Dvorak but didn't find it that much better for programming. It also had the large drawback that it became harder to quickly switch back to QWERTY when sitting down at someone else's computer and pretty much impossible for anyone else to use my computer. - Christopher Barber
(1) I use Dvorak right now because I can't take the time to get used to QWERTY again. Learning Dvorak was a net loss: I can't type any faster, it took a while to get proficient again, symbols are hard to get to, my wrists don't feel any better, and as Christopher was saying it makes switching/sharing computers really awkward. - IV.
[+3] [2010-05-09 18:20:53] Nauman

If Visual Studio [1] is in context, then there are several third-party plugin/tools which enhance typing efficiency of developers.

One such, I use is CodeRush [2]. There are even videos available for the same.


[+3] [2010-05-10 18:45:20] KitsuneYMG

Eclipse (and other IDE's I'm sure) has templates (menu Java -> Editor -> Template) where you can add you own pattern blocks. For example

if (${name:var} == null) {
    ${name} = new ${type}(${arguments});

return ${name};

gives you a nice fill-in-the-blank block of code that can be tab\shift+tab navigated until you hit eneter (then it's just regular text).

Also, Ctrl + Space brings up autocomplete.

I think this is a great idea. However it makes you think: if you do something often enough to make a template why not create a function? There are situations in which you don't want the overhead of a function call, but it is something to consider. - PP.
@PP An example (that ships with eclipse) is instanceof. It automatically puts if([NAME] instanceof [TYPE]) { [TYPE] [NAME]_ = ([TYPE])[NAME]; } into your editor. Where the [] are linked, replaceable text fields that can be navigated with tab (until you hit enter). - KitsuneYMG
[+3] [2010-05-14 18:18:55] RandomEngy

Remember that in Visual Studio if you copy or cut with no text selected, it will copy or cut the whole line. Then when you paste back in with no text selected, the line will be inserted above the line the cursor is on.

This has saved me a lot of time, especially when reordering a few lines. It makes dealing with leading or trailing empty lines a lot easier as well.

[+2] [2010-05-09 15:22:53] IAbstract

If you have the fourth and fifth mouse programmable buttons (and depending on programming software), set macros to your mouse buttons:

  1. Enter
  2. Cut
  3. Paste
  4. Build
  5. New class macro
  6. New getter/setter macro

This could save a lot of time. Think WoW [1], except really useful.


But why use the mouse at all? As a programmer, I mainly type, and rarely ever design graphics. My mouse is usually buried somewhere under books and papers. - sbi
To each his own. I use the mouse frequently. I have found that using the 4th & 5th buttons for cut/paste works very well and very fast. - IAbstract
I use the extra buttons for page up page down. That still helps a bit in coding, especially when your method is 2 pages long. - Jason
(1) I use mostly vim but I also enjoy using just the mouse sometimes. I added some context menu options for right click, like "Find the word under cursor", the same with a backwards search, "Open taglist"(methods and classes) and "Go to tag" so I can browse the code easily using only the mouse. - Heikki Naski
[+2] [2010-05-09 15:51:42] Norman Ramsey

Buy and learn to use a Kinesis contoured keyboard [1]:

I bought my first one in 1995 and I own five of them. To learn it, you are best off using a typing-tutor program, but once you've learned you can switch back and forth easily.


I have one. It saved me from having to get surgery, after 2 years of hardcore coding on a laptop for a startup. :) I love it. Using it right now. Every developer should seriously have the chance to try it out for a week. - Richard Hein
I'm not sure my typing speed would seriously increase with such a keyboard; it is already high using a cheap ordinary US keyboard (I do, however, baulk at UK keyboards, the shape of the Enter key and the tiny size of the left shift key seems completely impractical). - PP.
(2) It's not about the typing speed, in this case, but about keeping your wrists healthy - Adriano Varoli Piazza
[+2] [2010-05-13 19:25:36] robogeek1993

Zen Coding [1] is awesome. It's available for multiple IDEs, and it's great if you program HTML a lot, like me.

Get it here. [2]

It's also useful to press Ctrl + Space when using some IDEs, which will give you function parameter hints, etc.


[+2] [2010-05-26 07:38:53] Faisal

Easy Line Copy: Move the cursor to a line and press Ctrl + C WITHOUT selecting the text of line.

Easy Line Cut/Delete: Move the cursor to a line and press Ctrl + X WITHOUT selecting the text of line.

Easy Property Creation: Type prop and press tab twice.

Specific to Visual Studio, but useful. - Thomas
[+1] [2010-05-09 15:20:32] Bruce McGee

Depending on you IDE, you might have custom keyboard templates. which I find very productive.

For example, Delphi has live [1] templates [2] and Visual Studio has code snippets [3]. Both also have third party products that add even more functionality, such as Castalia [4], ModelMaker Code Explorer [5] for Delphi and CodeRush [6] (outstanding!) for Visual Studio. The only downside to these third party tools is trying to use a copy of the IDE that doesn't have them installed.


[+1] [2010-05-09 15:52:35] Sid Heroor

I use Emacs for my coding and there are couple of things that work for me.

  1. Use YASnippet.
  2. M-x comment-region and M-x uncomment-region help comment/uncomment chunks of code quickly
  3. show-paren-mode, with a background color like "honeydew2" helps in focussing on blocks of code
  4. Keyboard shortcuts tied to the key to insert (), [] and {}.

[+1] [2010-05-09 15:56:33] Norman Ramsey

If you use Emacs, do the tutorial (C-h t) all the way to the end.

If you use another editor, do what it takes to use the "fast navigation commands".

(1) If you use emacs, scrap it and learn Vim :). Now flame me :). - slacker
@slacker: if I were starting today I'd learn vim. But nobody is volunteering to port 28 years' worth of emacs lisp... - Norman Ramsey
[+1] [2010-05-10 05:37:14] Matt B.

Mac only: Use an editor that supports the native Cocoa text input system. Learn, modify and enhance the key bindings [1]. Remap the caps lock key to behave as ctrl.

All of this together amounts to a very comfortable way of navigating with the cursor sans arrow keys. By default, OS X implements a very minimal subset of Emacs commands. If you add in the word-centric commands (optionf moves one whole word forward, etc), you can reduce the number of trips to the mouse by quite a bit.

You can even implement complete and complicated snippets through the key bindings. For example, I have one like this:

/* This command will make Ctrl-< turn the previous word
 * into an HTML/XML opening and closing tag pair. */
"^<" = ( "setMark:",
         "insertText:", "<",
         "insertText:", ">",
         "insertText:", "</",
         "insertText:", ">",

[+1] [2010-05-11 08:22:24] MonkeyMagic

Picture: Alt text

  • Get a nice keyboard like the Logitech Illuminated.
  • Macros.
  • Autocomplete where possible.
  • An editor like E Text Editor [1] or TextMate [2] which does lots of things for you.
  • Plugins like Zen Coding [3] if doing lots of HTML.

Other than that..... staff ? :)


You can post a link to the pic, and somebody (e.g. me) will edit it into your answer. - Thomas
[+1] [2010-05-11 09:03:24] Lohoris

Rebind all your keys

On an English keyboard it may matter less, because programming languages has been invented using English keyboards. International keyboards have a different set or readily available symbols, usually different from the English ones, so many common symbols used in programming are hard to type on those keyboards.

For instance, { on standard Italian keyboard requires 1 key + 2 modifiers.

You will use the numbers much less than your most used symbols, so you should remap them to shift and use most used symbols to default.


Mac OS X

Edit the keys using Ukelele [1].


  • dump current keymap: xmodmap -pke >current.xmodmap
  • edit it by hand
  • load it in .xinitrc: xmodmap current.xmodmap

Disclaimer: I might not remember correctly, and there might be visual editors I'm not aware of.


I'm sure it can be done, or at least it could be done a few years ago. I never tried, but you can figure it out.


@Lo'oris: what operating system / application? Mac OS X? - Peter Mortensen
I have done this on Mac OS X, but it can be done on every system, you just have to find the right tool. Under linux you can edit by hand a custom .xmodmaprc, under windows I'm sure there's a program similar to this one (no idea how it is called). - Lohoris
I've edited, adding an explanation on how to do it. - Lohoris
@Lo'oris: Thanks. Some leads for Windows are in (in German, though) - Peter Mortensen
(1) on windows use MS Keyboard Layout Editor. (abbreviated MSKLC) Not perfect, maybe, but way more enjoyable than, say, ukulele, and it makes easy-to-run installers you can keep readily downloadable on your site (or on a USB key) and install on any windows machine you end up working on. - ZJR
[+1] [2010-05-11 15:37:27] Carl Manaster

Eclipse has a shortcut for looping over arrays and other containers. Type "fore" (short for "foreach") directly after an array declaration, and you get:

int[] myArray = new int[7];
for (int i : myArray) {


For other kinds of containers, it will generate an appropriately typed loop:

List<Integer> list;
for (Integer integer : list) {


But often I want to loop over a container that was declared elsewhere. I lose the benefit of automatic typing. So I create a variable, assign the container to it, use the shortcut, and immediately inline the variable.

x=l[ctrl-space][arrow keys as needed][enter]; produces x=list;

Quickfix (command-1) gives x the requisite type: List<Integer> x=list;

for[ctrl-space][enter] produces

for (Integer integer : x) {


and permits me to tab directly to the x, where I type command-option-i to inline, which deletes the List<Integer> x=list; line, and leaves me with exactly what I wanted:

for (Integer integer : list) {


It sounds like a lot of work, but honestly it saves me time - and errors.

[+1] [2010-05-11 22:15:55] Dan Menes

When entering large blocks of numbers for, e.g., initialization of arrays, don't use the numeric keypad, but instead move both hands to the number keys at the top of the keyboard. I was taught to do this when I worked in a data entry department at a bank in college, and I find it faster and more accurate.

(1) Ten fingers, ten digits... it makes sense. Do you use your thumbs as well? - Thomas
No thumbs--I still reach for 5 and 6. - Dan Menes
[+1] [2010-05-14 16:39:32] Heikki Naski

Search for the word under cursor to uncover typos

A great feature in itself, but you can also use it to check for typos. For example, * and # in Vim [1] and in Eclipse [2] wait for a couple of seconds when the cursor is over a symbol.


I use this feature so much I wrote custom functions to do this in Emacs. - PP.
[+1] [2010-05-14 22:07:59] Run CMD

For me the most valuable has been AutoHotkey [1].

  • You can reprogram your whole keyboard, as I did since I use AZERTY

    .. no more Alt + { to get "{", just type {, same with ( [ # @, etc. Who needs ùµ$^² as default keys anyway ?? WTF?? :-)

  • You can program your own shortcuts, for example ALT-² inserts a new method at my machine

  • You can program hotstrings, like if you type hotfunc, it will type a whole function declaration

  • Program hotkeys to launch EXE files, create files, etc.

  • You can use it in every application, including Visual Studio, Notepad, or your emails

  • You can do anything you want, since you can program it yourself

  • It's free


[+1] [2010-05-19 09:57:05] tim_hutton

In Notepad++ [1] there are two keyboard shortcuts that are perfect for programming:

  • Ctrl + Shift + Up/Down: move the current line up/down
  • Ctrl + D: duplicate the current line (or selected block)

i hate how ctrl+d does the exact opposite on zend studio :/ - Moak
[+1] [2010-06-28 15:09:43] Brian Hooper

Teach yourself to use the mouse with your less-good hand. Filling in dialogues goes a lot faster that way, particularly if the TAB navigation hasn't been programmed correctly.

[0] [2010-05-09 15:46:27] rabidmachine9

I think you have to try and use as many macros as possible. Editors like Emacs [1] can be really helpful, but most text editors now support a bunch of macros that can keep your hands on the keyboard and free it from the evil mouse...


[0] [2010-05-09 20:50:10] asmeurer

Get an IDE or editor that does code completion, and learn to use it well with the keyboard shortcuts. Most decent ones will complete variable names. Some, for example Xcode [1], will fill in things like if statements and switch blocks for you.

Then, you just press a keyboard shortcut (command-/ in Xcode) to move to the next spot you need to fill in. This does two things: it types out the stuff for you, and it keeps you from having to remember the exact syntax or making a mistake in it (you will never forget to break; a switch case if you do this).

Also, it doesn't work so well for programming, but for regular typing, use an editor that has good auto-completetion. The auto-completetion in Snow Leopard [2] has probably increased my effective typing speed by 150%. Maybe there is an awesome IDE out there that does this for comments.


[0] [2010-05-10 21:31:06] knittl

Learn an optimized keyboard layout like Neo [1].

The time it takes to learn pays off shortly after. All programming special characters are easily typeable without moving hands and fingers very far. Just press caps + some-key (caps + n = ( – n being j on a QWERT[YZ] keyboard :D confusing?). A numberblock and a cursor block including Home/End, PgUp/PgDn are integrated into the mainfield of the keyboard.

/**/ is on the homerow. {}()-*:/@? also on the homerow.

Move hands less, type more.


[0] [2010-05-10 21:53:22] AAT

I'm all in favour of knowing Vim [1], because of its portability (which is the reason I learned it back in 1993). I still use it sometimes even though I mostly work in Visual Studio, having used various flavours of it since, well, 1993 (Visual C++ 1.0 FWIW).

However more generally, I would say my top tips are:

  • Learn to type! None of the other ideas here will help speed you up half as much as learning to type quickly and accurately. Number one tip - stop looking at the keyboard
  • Learn regular expressions - complex replacements I still do in Vim because those are the regular expressions I know best, but Visual Studio 2008 [2] does a reasonable job
  • Learn how your editor supports quick macros - a lot of search + replace can now be done with refactoring tools, but now and then you want to reformat stuff repeatedly and a macro can save you hours of hacking about
  • Learn how your editor supports bookmarks: in Visual Studio this is Ctrl + F2 to leave a bookmark, F2 to go to the next bookmark. I am always amazed how few programmers know about or use these.

You should have put "learn to type" as a separate answer on it's own. - Agnel Kurian
@Vulcan - you mean because that is the most important speed improvement you can make? I won't disagree with that. - AAT
[0] [2010-05-11 01:56:06] Gabriel L. Oliveira

Find some site that can help you train your way of type. I don't know any other, but would be nice to see more of this on comments. This is an example to start [1]

[1] is also nice - Agnel Kurian
So nice too man! It has more features, but is some confuse on the keyboard color. But liked it so much. Thank you to share with us. - Gabriel L. Oliveira
[0] [2010-05-11 08:38:17] Will

I find I can type Pascal faster than C/C++ because it contains far less obscure punctuation symbols - therefore requiring far less two-hand coordinated movements to type them.

On many non-US keyboard layouts you need three-key combinations to generate the various brackets {[]}

The keyboard is optimized (yes, optimized to avoid jamming typewriters by putting alternative characters on alternate hands) for text input, not complicated symbols.

If you can't use Pascal, Cobol or Python or another language with this word-based style you might be able to adopt something similar [1] as early Unix apps did.


(1) That header is horrible. When writing C, write C, don't try to make it look like Pascal. - Thomas
@Thomas I second that; never re-define a language if you ever expect any body else to see/use your code. It is the equivalent of walking around in hoodies with your jeans halfway down your legs showing off your underwear. Not cool. - PP.
@PP and @Thomas it could be that that particular file is infamous if you're steeped in the history of our trade? Do you think I found it by accident? :D - Will
of course, the serious point about punctuation being difficult on my (non-US) keyboard is an serious contribution to the discussion, and I stand by that bit - Will
If you touch-type without looking at the keyboard, just change the layout to qwerty (or something else suitable for programming). If you don't touch-type, maybe that is the place to start :) - Thomas
@Thomas I have a non-US keyboard because I have a non-US keyboard in a non-US country and do need to type non-US strings, even in my program source. Saying programs should be written in ASCII with US comments and strings is not a very nice sounding solution is it? - Will
I'm not saying that; I'm well aware how annoying such issues are. However, the code itself is ASCII in all but a few programming languages. You could consider externalizing your strings, so you could switch your layout when you're going to work on the UI side of things. Comments, of course, are a more difficult matter... Unfortunately there is no perfect solution. (I wonder if one could hook up two physical keyboards and set each to a different layout? Would the OS understand?) - Thomas
@Thomas so giving that the comment symbols /* in C were chosen because they were on top of the US standard keyboard numeric pad at the time - were there international keyboard layouts at that time? - and the question is asking things that let you edit code faster, using a non-{} language is a good way of achieving that for many people, and you could upvote this answer because its patently valid? :D - Will
[0] [2010-05-11 14:16:38] Malice

This is Visual Studio-specific but it also works with Notepad++. Basically it's possible to use the keyboard to scroll the current window leaving the cursor in the same place by using Ctrl+Up or Ctrl+Down.

It's maybe not that useful however as once the cursor reaches the top or the bottom of the screen it will stay there. I use it periodically if I need to check something that I know is just beyond the current window boundary so I can scroll the window up or down without having the cursor move off the current line.

[0] [2010-05-11 15:02:50] Christopher Barber

Learn to use incremental search for navigation.

Most modern text editors provide some sort of incremental search capability, for instance in Eclipse this is bound to Ctrl+J by default while in Emacs it is bound to Ctrl+S and in Visual Studio it is Ctrl+I. You can use this and its reverse version to jump to code at or near where you want to place your cursor rather than mousing or using simple arrow controls.

[0] [2010-05-11 17:07:02] Jay

Challenge your coworker(s) to a contest. Pick some action you do often and give kudos, prizes, etc. to the person who comes up with the fewest keystrokes/button pushes to accomplish it. Examples:

In some versions of vi zz will close the file and save it. This is one keystroke shorter than ':x' then the enter key.


In Windows you can copy a file's name in Windows Explorer by right clicking on the file, hitting rename, then hitting Ctrl + c to copy the highlighted file name from the rename input box.

Click, F2, Ctrl+C would be my choice. Alternatively, click, wait, click, Ctrl+C, but that's slower. - Thomas
[0] [2010-05-11 22:27:46] Dan Menes

drelihan mentioned the "go to matching brace" shortcuts in Visual Studio and Eclipse. In TextPad [1], it's Ctrl + M, or Ctrl + Shift + M to select the entire block.


[0] [2010-05-13 14:27:56] Kevin Reid

Learn or create a shortcut to take the selected text and perform a search for it. On most Mac editors, this is ⌘E ⌘G. This allows you to do a quick “find other occurrences of this symbol” to navigate around the relevant parts of your file.

[0] [2010-05-13 15:09:57] David Wolever

Context-insensitive Completion

In Vim, ctrl-{n,p} and Eclipse I think the default is meta-/.

It's powerful because it doesn't care if you're writing documentation (I cringe every time I see someone typing out a comment which contains, say, … call ISomeEnterpriseBusnessClass.fozzleTheWidgetWithTheWazzle…), writing inside strings or writing code.

[0] [2010-05-13 15:23:09] Sorin Comanescu

In Visual Studio (plus EnterpriseManager's editor), comment and uncomment using Ctrl + K + C and Ctrl + K + U. Nice thing, it works well with different languages.

[0] [2010-05-19 10:24:45] Agnel Kurian

In Visual Studio 2008, map a good pair of keystrokes to the Edit.GoToFindResults1NextLocation and Edit.GoToFindResults1PrevLocation actions. Saves a lot of time when changing something across multiple files in cases where 'Replace in files' is not an option.

(Ctrl + ;, Ctrl + N and Ctrl + ;, Ctrl + P are decent enough setting here)

[0] [2010-05-19 18:02:08] SystematicFrank

Type and edit code faster? Master your tools! Whichever tool you are using, learn to use it at its fullest. The first thing is the editor, Vim [1] is amazing, Emacs [2] too. At least it is very important that you can expand its functionality with macros.

Also learn tools for browsing code like global and cscope [3]. If you cannot find what you want fast, you cannot edit fast.

Being more generic, learn some code spelunking [4] to move faster even when the code is totally alien to you.


[0] [2011-03-13 09:28:24] Pete Wilson

I switch back and forth between vi [1] and Visual Studio [2] a zillion times a day with the predictable result that I type vi commands at Visual Studio; and vice-versa.

This very helpful thread inspires me to find/make some vi keyboard macros that also work for Visual Studio. That would save me tons of time.


[-5] [2010-05-09 21:57:28] Puppy

Abuse your language's preprocessor.

#define J template<typename T>
#define LOOP(a, b) for(int i = 0; i < a; i++) { b; }

Saves so much time!

(7) This sounds like a great way to make your code unmaintainable. Using an editor with snippets is a much better idea. - shosti
(2) @eman agreed, this is an anti-pattern. It's also job security, so I guess you could say you've killed two birds with one stone! Don't forget to throw this into a common header file to be truly evil: #if COUNTER & 0x1 == 1 #then #define long int #endif - Ed Griebel
(2) -1 for making fellow coders' lives more difficult. This is anti-social. - PP.
(1) It was clearly intended to be humourous, PP. - Puppy
[-5] [2010-05-13 00:30:36] Nathan Osman

I assume growing an extra finger is out of the question?

Seriously though, I recommend extensive customization of the function keys on your keyboard and mouse.

[-11] [2010-05-09 14:51:19] Andrew Heath

Learn the hotkeys and shortcuts, all of them -- even the ones you're sure you'll never need to use...

You will someday, and you'll be prepared.

(16) No you won't. The ones you never use, you will have forgotten by the time you want them. - Conrad Albrecht
(6) This is pointless. These things work on muscle memory. If you'll never use them, you won't remember them. - Rubys
(1) It is much more important that you take the time to learn the shortcuts you will be required to use often. You will be wasting any time you take trying to learn shortcuts you don't think you'll ever use. - IAbstract
(1) If you have to fetch a keyboard shortcut from the depths of your memory, you would be better not memorizing it and just using the mouse. Like Rubys said, keyboard shortcuts are only "shortcuts" if they work on muscle memory. - R. Martinho Fernandes
(6) I think perhaps this should be rephrased - you should be aware of the existence of all of the shortcuts, even if you don't use them, since one day you might have to do something repeatedly and if you know there's a shortcut for it, you can look it up. - Daniel I-S
I agree with Daniel I-S that it's good to know a lot of the capabilities of the tools. For example, I printed out :h index.txt of vim, about 18 pages I think, and went through that list putting a tick in the margin if the feature sounded good and then incorporated some of those in my daily editing, just a couple at a time. - Heikki Naski