04 November 2016
(2018 note: this post is woefully out of date on the specifics, but 2 years later, I’m still use the same basic setup. I’m leaving the post here unedited for memory’s sake.)
A few months ago (in August), I switched from Atom to Vim and started getting serious about my terminal development environment.
I could talk about how awesome Vim is, how it’s changed my life and solved all my problems and purified all my toxins. But this post isn’t about preaching the Gospel of Vim. I just want to document my first real terminal setup.
Even though I’ve been “using the terminal” for years, I never spent a lot of time making it a nice place to be because it wasn’t the foundation of my development environment. Of course, that changed when I became A Vim User.
I’m not someone who lives for configuring things, but (with lots of guidance) I eventually ended up with something I think is pretty nice.
First things first: figure out which terminal to use. There are a few options other than your system terminal. I think the two most compelling are:
I tried these and others, and even used iTerm for the first two weeks of my setup, but I ended up going back to the OS X system terminal — Terminal.app — and I have no regrets.
Note that Terminal.app only supports 256 colors. iTerm and hyperTerm have 24-bit color and lots of other cool features, but they just didn’t outweigh those two factors for me.
Vim is the reason I switched to a terminal-based dev environment in the first place. It’s an old-school text editor that uses keyboard commands to navigate and manipulate text. If you’re a “power-user” of any software ever, you already understand the advantage of keyboard shortcuts (once they’re in your muscle memory, of course), and using Vim takes that to the extreme.
Vim keeps my hands on the keyboard and my ideas flowing. It’s simple and customizable, it never freezes, and it gets out of my way. More so than any other editor, it makes me feel like the computer is an extension of my brain.
If you think Vim users are just hipster neckbeards, I feel ya, but don’t totally discount it until you try it as your daily driver for at least a week or two. If being a hipster neckbeard is wrong, then I don’t want to be right.
To start out, open your terminal and type
vimtutor. Spending 15-30 minutes a day on this for about a week will be a good primer. After you’re familiar with the basics, I recommend just going cold turkey. It’ll suck the first few days, but after about two weeks, you’ll be back up to speed.
Vim is crazy powerful and flexible. You could learn a new command a day for years and still not know everything. It’s easy to get overwhelmed. Just know you can start out with the basics and still be productive, and add special commands to your workflow over time (the fun part). There are lots of resources for Vim commands, but here’s my cheat sheet. It’s obviously not exhaustive, but it covers most of the basics as well as a few handy commands I took note of in my first week or so.
“the future of vim.” This adds some nice stuff to Vim. It’ll make it feel a bit more user-friendly by introducing some modern interactions like being able to scroll or change the split pane size with your mouse. Install it with homebrew (oh, and get homebrew if you haven’t already!)
Vim can be endlessly configured. As a True Vim User, your .vimrc is something that should be carefully curated line-by-line, cherished, passed down from generation to generation, and eventually engraved on your tombstone.
You can start out by enlisting the help of someone else’s dotfiles. Lots of people share them on GitHub. Here’s what I use: cp-dotfiles.
It’s lightweight but comes with some really handy things that are now essential to my workflow. Even if you don’t use the same repo, these settings can of course be added to your own configuration independently. (check out the settings folder, and also Vundle, a Vim plugin manager.)
If you have a friend or teammate who uses Vim, ask them for recommendations. Most importantly, don’t worry too much about getting your configuration 100% perfect the first time. Start with the basics, and over time you’ll add your own settings and tools as you discover annoying or inconvenient things in your process.
A nice shell. You won’t have to learn anything new coming from bash, but you’ll get more customizable prompts, better autocomplete, and some other handy things. Install it, then you’ll want to pick a prompt theme. Check your available prompt themes with prompt -l, then choose one with prompt promptname. I like smiley or cloud. Nice and simple with handy git info when you’re inside a git directory.
If you want to really dig in and customize your prompt further, go check out ~/.zprezto/modules/prompt/functions, duplicate the one you want, give it a new name, and hack away. Remember you’ll need to reopen a terminal session to see the new prompt in your options.
I’ve also heard really good things about fish shell, but I haven’t gotten around to trying it out myself yet.
Tmux is a really important tool in my workflow now. It lets you split your terminal into panes and run multiple sessions (think tabs).
I usually have a session open for each project, where each session has a large pane on the top for Vim, and two or three small panes on the bottom for doing git stuff, running tests, running servers, watching/building, etc. You can rename each session so it’s really easy to get where you need to go.
There are a bunch of commands to manage your tmux panes. All the shortcuts I use are at the bottom of my cheatsheet.
Colors are important. When first switching from Atom, I was really annoyed that my Vim/terminal colors looked like garbage when Atom has such a pretty default colorscheme. But we can fix it!
First, we’ll need to make sure that everything is set up for 256 colors (not 24-bit, since Terminal.app doesn’t support that).
.tmux.conffor the line that looks like
set -g terminal-overrides ",xterm-256color:Tc", remove/comment it, and add
set -g default-terminal screen-256color.
set background=darkin your
.vimrc. (Or light, but I’m gonna just assume you want a dark theme…???)
Now you’re ready to try out some colorschemes. Here are some of my favorites to get you started: brogrammer, hybrid, apprentice, sierra, tender. You can find more at vimcolors.com and really go crazy if you want.
To install the “hybrid” colorscheme, for example, copy the hybrid.vim file into
~/.vim/colors, then try it out by opening a file in vim and typing
:colorscheme hybrid. If you decide you like it and want it to be your default colorscheme, add a line with
:colorscheme hybrid to the bottom of your
Terminal colors are configured in the Terminal.app profile preferences under “Background” and “ANSI Colors”. Some color schemes come with terminal colors you can download and use, but it’s also really easy (and worth it) to get your terminal to match all by yourself: there’s a color picker which you can use to grab colors straight from your code.
If this seems like too much work, just use one of the pre-loaded profiles, and maybe just change the background color to match your Vim background color.
You can choose your font, size, and weight under your Terminal.app profile settings.
Some fonts include programming ligatures to make programming operators pretty. This is totally optional and a matter of personal taste. According to my personal taste, ligatures are the best. Download and install the font Fira Code and enable it under your Terminal profile settings.
Open a file in Vim and type in some programming symbols like
=>. Hellooooooo handsome.
I don’t know who decided to put the most useless key in such a prime spot on the keyboard, but let’s remap it because you’ve probably never purposely caps-lock‘d in your entire life.
The options are endless (well, not literally, but, uh, there are a lot of options). I think these two make the most sense:
It just comes down to personal preference. I chose option 2, as have most of my Vim-using teammates.
Well, we’ve done it. We’ve reached Terminal Nirvana. Now we can relax and enjoy our hard work by getting some work done.