How I

Andre Torrez

Software developer and occasional hacker

San Francisco, CA

Who are you and what do you use Vim for?

I’m a software developer who lives and works in San Francisco. I work at Slack and before that I had a bunch of projects that I don’t work on any more.

I use Vim solely for writing code. I’ve tried using it for writing blog posts or note taking but I think it’s uncomfortable for that and so I stopped. I will say I’m a Vim novice and I probably learn something new every week, so maybe I’ll rethink the code-only rule when I get better.

I first used Vim like most people: in a panic because ctrl-c did nothing and my only resort was backgrounding the job and killing it. This was in the mid-90s while tinkering with Linux. Over the years my usage of Linux grew but Vim was always something I had to use because it was the only text editor that was always available. I could :wq and u plus a few other things and that was good enough for conf files.

A few of years ago, while getting by with my ci" and dd, I found myself administering a bunch of Linux machines and I decided to finally figure out what the heck I was doing with Vim. I knew what ci" did, but I couldn’t tell you why. So I went all in: full-screen on my Mac, deleted SublimeText, installed Janus, NERDtree, a bunch of themes, a bunch of snippets from other people’s .vimrc files, and anything else I could get my hands on.

It was a disaster! I wasn’t learning Vim at all. I was learning how to use all the add-ons and configurations from people who had been using Vim for a while thought they might like. I had no idea what I actually needed.

So I started over with an empty .vimrc and have slowly (very slowly) added lines as needed. And the funny thing is the longer I use Vim the more I realize I don’t need very many lines at all.

My work computer is a Chromebook Pixel. I run a chroot with a headless Ubuntu (Trusty) inside of it and therefore whatever version of Vim that installs when you run apt-get is what I use. I switched to this setup after many years of trying to replicate production environments (Linux/Ubuntu) with development computers (Mac OS X). I was tired of the gymnastics required to build certain libraries when on my Linux servers they just worked.

Being able to get my work done using Vim made it that much easier to switch. I didn’t really consider it until I answered this question but I never would have been able to switch to the Chromebook had I not spent a year getting competent with Vim.

Introduce us to your Vim config.

It’s 17 lines! I’m just going to comment on the sections:

execute pathogen#infect()

For ctrlp, vim-gitgutter, and vim-surround, but I often forget I even have vim-surround. I should probably use it more.

syntax on
filetype plugin indent on

I write a lot of PHP and Python and the two styles could not be more different.

set list
set lcs=tab:\|-,trail:-

I adored the invisible character view in SublimeText and I tried to replicate it. It’s not nearly as nice.

set autoindent
set tags=tags;
set hlsearch
set incsearch
set ruler
set number

Some standard stuff here. ctags are my life.

nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>

I swiped this from someplace when I was into splits. They’re shortcuts for switching focus. I use tabs now, but occasionally I will need these for a file split or :help.

set runtimepath^=~/.vim/bundle/ctrlp.vim
set shell=/bin/bash

Bundle settings. The second line is because I use Fish shell and vim-gitgutter won’t work with it so I have to override my shell in Vim.

I know this is a pretty sparse .vimrc. I keep it in a private repo now with my Fish shell config so I can drop it onto any system I plan on using a lot. The nice thing about my config is that if I do find myself on a vanilla install of Vim I don’t feel like I’m missing too much.

I don’t think this config has changed significantly in over six months. I keep meaning to set up ctrlp to use ag (Silver Searcher) and I might do that now that I just Googled how to do it. But otherwise I’m pretty happy with this setup.

You’ll probably notice I don’t even have a colorscheme! I used to use Solarized dark on my Mac but I like the default ChromeOS color scheme so much I didn’t even bother changing it when I got the Pixel.

What have been the most useful resources for you to learn Vim?

I read Practical Vim by Drew Neil in a day when I rebooted my .vimrc. Now I just use :help whenever I get in a jam. Or I Google something that sounds like the thing I want to do and read from there. I probably end up on at least once a day. I think I could just use :help but sometimes I have to describe what I want to do and let Google point the way.

What’s the most recent thing you’ve learned about Vim?

Registers! I never paid attention to them because it felt so awkward typing that many keys to save something. When I used to work on a Mac I’d rely on a clipboard manager that kept my last 100 copied strings. I didn’t realize Vim was doing this from 0-9 and I was ignorantly using named registers when I got myself in a jam.

It really pays to remember to use :help somefeature even when you think you know what somefeature does.