The Pragmatic Programmers advise us to “use a single editor well,” letting it “…be an extension of your hand.” If you’ve ever watched an experienced developer, it can be quite dispiriting to see just how effectively and quickly they can work. IDEs both old and new have such a dizzying array of facilities that it can take a very long time to learn a tool deeply.
Lately, I have been working with both new developers and developers who are new to the tooling. It’s a given that for those who are new to a tool or platform, there will be more information than they can internalize in just a day or two. So where’s the best place to focus?
I can’t say much about platforms or APIs, as those differ so widely. But for an editor, the goal is always the same: to extract the code from your head and put it on the screen.
Here’s my un-asked-for and opinionated list of the things I think are key. If you’re overwhelmed by the sheer number of features and key commands, try starting with these five. Any item on this list should be possible with any editor worth its salt, and in my opinion, they’re some of the best bang-for-your-buck tools.
1. Moving Code: Copy + Paste and Comment + Uncomment
Being able to move your code around is one of the most critical and basic tools. It may sound trivial, but I don’t think it is. Moving code around is the building block of so much experimentation, and an inefficiency here can prevent you from trying out the thing you want to do.
Similarly, I’ve found that I often comment and uncomment code. Many editors have this bound to Control-/. I use this tool a ton. For example, I often drill down into a specific path and comment out the last half of a function while I’m examining it, or I use it to try alternate phrasings. It also comes in handy when I’m working on a test and want to disable a few assertions until later.
2. Trying Code: Save and Run
The other half of experimentation is actually running the experiment. If you’re doing TDD, don’t waste time moving your mouse to click the ‘run’ button. Just press control-F5 or whatever you’ve bound to it.
3. Understanding Code: Indenting and Reformatting
I hate ugly code. Not for its own sake (though I am a bit obsessive that way), but because over the years, I’ve built my instincts and trained my expectations. I expect related things to be grouped together. I expect nested things to be indented further than unindented things. It makes it easier to read.
But it’s not just for the human. Automatic indenting is a terrific clue to compiler errors. Sure, I could count braces…but why? Automatic indenting often solves that for me.
Life’s too short to waste precious brain cycles trying to understand ugly, poorly indented, poorly grouped code.
4. Understanding Code, Part 2: Viewing Two Things at Once
I almost always have two columns going in my editor. Almost always. I’ll do this to:
- Edit an API while I view the API’s consumer
- See code and test at the same time
- See source and headers at the same time
- See sample data and my code at the same time
My memory isn’t good enough to work without a reference, but fortunately, there’s almost always a way to do that in any modern (and also in the most archaic) editors.
5. Navigating Code: Jump to File or Symbol
One final tip: Find out how to jump around your project easily. It’s rare that I have projects that fit in a single file. For example, Rails produces piles of directories and organizes many different kinds of files in them.
Whether it’s using Vim with Ctags to jump to symbols, or just jumping across filenames, or some sophisticated Intellisense—learn it. There are often different versions for classes or types or files, but don’t sweat those. Just pick one and use it a lot.
Useful Tools
There are a ton of possible tools and shortcuts, but these are my top five that I use everywhere.
These are the most fundamental basics that have the biggest individual effects on my day-to-day workflows: moving code around, trying code out, viewing, and navigating. Most of the rest of what you do falls into one of those categories. If you can master and fully internalize a few of the simple tools, you’ll find it to be a tremendous boon to your productivity.