When it comes to my choice of editor, I find that I’m a nomad. I’m always switching around based on the needs of my current project and the editor I’m using. If I squint hard enough, VSCode starts to look like Emacs. Over time, I’ve found a few editor features I can’t live without.
## 1. Inline Documentation
This one is pretty basic, but essential. If my editor isn’t capable of showing me some basic documentation about functions as I type or navigate, then I’m going to switch to something else.
Ideally, this would include:
- The doc string of the function under your cursor
- Any relevant type info
- Names of the arguments to the function
It’s also really important that it applies equally well to both your own code in the project _and_ any third-party code or libraries you may need.
## 2. Symbol-Based Navigation
As codebases get large, I often lose track of where I defined my functions. Primarily for that reason, I can’t live without symbol-based navigation which lets me Command-Click or press some keyboard shortcut to jump to the definition of whatever I’m looking at.
There are two related features here that I consider a bonus:
- An easy keyboard shortcut to return to where I was before. Extra bonus: the ability to treat it as a stack, so I can dive down and back up multiple levels of code without keeping track of a bunch of files in my head.
- The ability to jump into the source code (or type definitions for) a library you’re using. Sometimes it really helps to just look at the code.
## 3. Real Auto-Complete
By “real,” I mean that it’s suggesting actual functions or symbols within the project in roughly the right places.
Ideally, when you select a completion that’s not already visible in your current file, it should auto-import. If you’re like me, it’s not like you’ll remember where that function was from anyway.
## 4. Auto-Format
This is one I’ve only recently begun using. I have my editors set up to invoke Prettier for our TypeScript code upon save.
It’s unexpectedly liberating to offload the work of visually formatting your code. Perhaps this could fill its own blog post, but picture this:
- Add a few lines of code without worrying about white space, indentation, or even inserting your own newlines. Save the file, and everything is nicely formatted.
- No more thinking about how your style differs from that of your colleagues. Everyone’s code comes out roughly the same.
## 5. Live REPL
If I’m using a language with a REPL (especially true for lisps), I absolutely can’t live without REPL integration.
Having the ability to invoke bits of code from within your source file is really powerful. It makes your code feel more like an interactive environment.
## 6. Structural Editing
When you’re writing code, how often do you find yourself in one of these scenarios?
- You have some code that was placed inside an `if`, but now you need to always execute it. Or, perhaps you have the opposite situation.
- When editing HTML/XML, you’d like to remove a parent element, but leave the children in place.
- You’re renaming a tag, and you need to rename it in the opening and closing ends.
- You have some code or HTML that you’d like to move out of a parent, but leave the parent in place.
I’m sure you’re already imagining how arduous it is to make these changes by hand: jumping between lines, adding or removing curly braces, cutting and pasting.
Remember that all code is a tree; all of these operations amount to slight reorganizations of that tree. When your editing assists you with these kinds of operations, it’s often referred to as structural editing.
Although it’s a lot less common to run into editors that naturally assist you with structural editing, it’s definitely worthwhile.
It’s a great feeling when, in a single keyboard shortcut, you can do what would have taken a bunch of typing and/or mousing. Once you experience it, you won’t want to live without it, either.
If your current setup is missing any of these, I’d encourage you to invest some time to see if you can fix that.
When thinking about this post, I was also surprised by some of the things I actually don’t care that much about. For example:
- Vim bindings
- How an editor manages tabs/buffers
- The ability to run tests or build the project inline (if that’s arduous, I tend to use a Makefile or some other tool to help)
- For that matter, shell integration
I spend most of my time in a terminal and SSH into various boxes daily. I do customize my standard Unix toolset, but avoid plugins and non-standard configs that increase the cognitive burden. It’s very liberating to feel comfortable with shitty defaults. If you feel at home with the defaults, you feel at home anywhere.
Comments are closed.