I get asked pretty often for tips on how to improve working / learning efficiency. I usually give the same answer, so I figured I’d document it here, as I don’t always have time to go into sufficient detail on the spot. This post was originally about why you should learn vim, but I figured it would be good to contextualize it more broadly.
- Learn to learn better
- Learn to computer better
There are two big concepts I’d like to bullet point (well, 2 and a half, let’s say)
1: Develop Honest Learning Habits - the number one given, and it’s actually pretty straightforward: if you want to learn a language, you have to start using it. Videos and tutorials are lovely resources, but somewhat deceptive. You feel like you’re learning, and certainly to some extent you are - but at best you’re learning to memorize code, not produce it.
As soon as you can declare variables and push values around, you’re ready to start writing programs. Hesitation is understandable - “Maybe a couple more how-tos, I don’t feel quiiiite ready.” - but just put that aside and jump in. You’ll run into problems, I guarantee it. Google them. That’s what real work looks like - figuring out how to solve your own problems.
I know, it’s not nearly as much fun as kicking back and watching a video. Forgive me for the curmudgeonly aside, but contrary to what most of the marketing imagery popping up in your Facebook feed might suggest, learning to program isn’t always fun:
To sum it up:
- Write code
- Google errors
- Don’t smile (just kidding, please do)
2: Become a Power User in your own right. IMO this gets overlooked way too often, and it’s way more important than you think.
Despite what you might have heard, this isn’t just an ivory tower pass-time reserved for the nerdiest of nerds, fiddling with window manager configs or tailoring their system’s C / C++ compilation flags to their CPU architecture. It’s a broadly-defined, on-going process of learning to understand and augment your everyday computer usage.
First and foremost - use keyboard shortcuts.
Look at it this way - for every trade, there are tools. What’s your most valuable tool as a developer (besides your brain)? Right, your computer. Your ability to use your computer directly affects your ability to translate thoughts into programs.
Writing code uses enough brainpower as it is. Every unnecessary movement you make hinders your ability to efficiently translate ideas into code - I call this cognitive friction. Learning keyboard shortcuts will reduce that friction, allowing you to work faster and more effectively.
If I haven’t convinced you yet, try this: make sure Atom is running and minimized, then use your phone’s stopwatch to record the time it takes to move your mouse from this browser window and over to Atom. At best, I can do 3.35s.
Now, try it again, only this time use
Command - Tab (
Alt - Tab for Windows / Linux). In this case, it took me a less than a second.
How many times do you switch between your editor and your browser / terminal when you’re working on a project? 20 times? 50 times? Do the math, I think you’ll see which way is better.
Here’s a list of my favorite shortcuts:
* `Command - Tab / Command - Shift - Tab # Cycle active window forwards / backwards` * `Command - 1 / 2 / 3 ... 9 # select first tab, second tab third tab, or last tab (Chrome and Atom)` * `Command - R # Reload (Chrome)` * `Command - Space # Spotlight search (you should almost never have to use finder to open an application)` * `Command - S # Save (Atom, Word, almost any GUI application really)` # Got a lot of words to delete? Instead of just holding Backspace for the rest of your life: * `Command - Backspace # Delete to beginning of line` * `Alt - Backspace # Delete single word` * `Command - [ / ] # Indent backwards / forwards` * `Command - D # Find and select next instance of currently selected word(s). This one rules!` * `Command - F # Find in page (both Atom and Chrome)` * `Command - G / Command - Shift - G # Cycle through search results forward / backward` * `Command - T # New Tab` * `Command - Q # Quit`
2.5 - The grail: Learn Vim (and a touch of Emacs)
Let’s face it, writing and editing code is pretty awkward. The weird syntax, punctuation, tabs, whitespace - the hand acrobatics aren’t very intuitive.
Enter Vim. You might’ve heard of it, maybe even been scared off by the esoteric power-usery vibes it puts off. Doesn’t have to be that way! I’ve figured out a gradual process that will get you up and running. It’s weird at first, but oh-so-worth-it in the long run.
In terms of reducing cognitive friction, maximizing efficiency while editing, Vim is without a doubt the most bang for your buck - and no, it doesn’t cost anything.
Here’s a look at what you can do with even the most basic movement / insertion commands at your fingertips: https://youtu.be/Mn3B859Frq8?t=10s
Please don’t get spooked by the terminal-heavy interface - you don’t need to go to these lengths to become an effective Vim user! Keep reading - you don’t even have to stop using Atom
Vim is older than dirt (at least its predecessor
vi is) - and most *nix / BSD machines will come with it installed. If you have macOS, you can go run it right now!
vimin your terminal.
Not only that, but your computer also comes with a vim tutorial!
vimtutorin your terminal to get started with the basics.
While Vim is traditionally a terminal-based application, I think the best way to start using it is with a plugin for Atom called vim-mode-plus. That way, you can learn the basics, but fall back on the mouse or arrow-keys if you need to.
Like I said, Vim is weird at first, but it’s not intrinsically difficult - there’s just a lot of repetition at first. I think anyone can and should learn it. I myself started learning it when I was only 12 weeks into the program at ACA, and within a couple weeks, knew enough to start using it all the time.
I recommend looking at this “gradual approach” booklet and referring to this most-commonly-used keys guide I wrote a while back.
Vim isn’t just a better way to edit - it’s a real skill you can cite on your résumé.
Let’s say that your first day at a new job, your super tells you to
ssh into a remote machine with your terminal (
ssh, if you don’t know, is a way to log into a terminal on another computer over LAN or the internet.).
If you need to edit a file on that computer, how would you do it? Remember, you don’t have access to a GUI. Maybe you’d use
nano - not the greatest editor, but better than nothing. Otherwise, you’d have to find some way to transfer it to your local machine, edit it, transfer it back, do the whole thing all over again if there are any errors. What a pain!
vim, you could edit the file right in your terminal, with all the keystrokes you’re familiar with - just as if you were editing on your local machine. And score some big kudos with the higher-ups at your job
Now, the most commonly-cited alternative to Vim is Emacs - another older-than-dirt editor that remains a favorite in the community. I think Emacs is awesome, and I’d love to use it more at some point. However, I think Vim’s simplicity & ubiquity make it worth learning first.
One big advantage of Emacs is that, unlike Vim, the common movement / insertion commands will work just about anywhere. I’m actually using some right now, as I write and edit this post in the browser. However, these keybindings are especially useful in the terminal, since you can’t just click somewhere on the command line to move your cursor some where. Usually, you just have to hold down the arrow keys to move where you want.
If you find any keys you think should be in there, feel free to submit some edits! You can do so right in your browser.
Phew, that was a lot of info. I think the only thing I’d add is learn the command line - this short guide will get your started off on the right foot. Of course the best way to learn is by using it (and messing around with Linux, but that’s a whole different discussion…)
Hope you guys found this useful. Let me know if you have any questions!