How I

Steve Francia

Author, hacker, speaker, leader, Gopher

New York, NY

Who are you and what do you use Vim for?

I am Steve Francia, better known by my handle, spf13. I am a hack(er) of many trades and love to make open source software that I and my friends enjoy using. Early in my career I was a Unix Systems Administrator. I got my first taste of vi on DigitalUnix, SunOS and FreeBSD. This was in the very early days of the Internet (1995) and before the term open source was coined. As my career progressed I held roles as a DBA, network admin and then a software engineer. By the early 2000s I entered the world of management.

I currently work for Docker as the Chief Operator responsible for our open source operations, prior to that I created, built and led the Developer Experience team at MongoDB which included Engineering, Docs, Tools, Web and Evangelism. I have written a book which is published by O’Reilly and contributed to a few more. I blog at spf13.com. I am probably best known for my open source contributions which include spf13-vim, a popular vim distribution and Hugo, the fastest and most powerful static site generator.

I use Vim for virtually anything that I have to type more than a line or two. Even if it’s intended for another destination like an app like evernote I’ll usually type it in Vim and copy it over. I’ve written a book in Vim. Every single blog post and too many applications, plugins and libraries to count.

These days most of my writing consists of Markdown for docs, blog posts and web content; html, css & js for web stuff; Go for development; and VimL and shell scripting. Until I started writing Go I was very much a polyglot developing in these languages plus Perl, Python, PHP, Ruby, Scala and very rarely C or Java.

Introduce us to your Vim config.

Like many people I’ve been maintaining my personal vim configuration for as long as I’ve used Vim. I started with a completely blank .vimrc file and as I understood a configuration parameter I would add it along with commentary. This isn’t entirely accurate, it was definitely messier than this, but as this was over a decade I prefer to remember it favorably. I had three, perhaps unusual goals for my Vim config:

1. I wanted it to improve but not change things.

I spent years getting really good at vanilla vim and appreciated the thoughtful and calculated way it is designed. I would sometimes sit at another persons terminal and feel completely lost. I’d use things like cream and hate how it changed everything that made me love vim in the first place. I also found things in Vim that I didn’t like. Some of my most common operations were 3 or 4 keystrokes and felt needlessly so. I tried to optimize these operations into a single keystroke or at worst a chorded (shift+letter) keystroke. I had a rule to never change a default action and with very few exceptions I was successful at this. The benefit to this is that using my vim configuration feels very friendly. Even if you are on a machine with the vanilla configuration you may miss some of your shortcuts, but you will still feel right at home.

2. I wanted it to be super easy to install.

As I mentioned, I use vim for everything. I wanted it to be everywhere I was working. I didn’t have time to spend manually configuring everything for vim when I ssh’ed into a new box. As a lazy sysadmin, I love to automate things especially when I do them over and over. I scripted a quick installer to make it easy to checkout my vim configuration and install all the plugins and dependencies.

3. I wanted it to run everywhere I worked.

I commonly develop on a Mac laptop, write on a Windows desktop and run Linux on my servers. I needed Vim to work everywhere I did and didn’t want to have to worry about installing specific versions of dependencies like python 2.x or recompile Vim because it was missing a feature.

As tools like SVN emerged I put my vim configuration and installer online so I could easily install things from a variety of places and track my improvements. Without giving it much thought at all I called it spf13-vim. In time a few others found my vim configuration and began to contribute improvements to it.

As the contributions continued to come it I realized a few things.

  1. My vim configuration appealed to a lot of people who were using it as their Vim config
  2. A lot of people wanted mostly the same vim configurations & plugins.
  3. Most people have a few things they want unique just to them.

As a result of this I added the ability for people to add their own fork of my Vim in a way that made it easy to keep up to date with upstream.

When Github came around I moved my configuration on there and things really took off. Thousands of people today use spf13-vim as their Vim configuration.

There have been three major (public) versions of the configuration. The first version used a script which installed the plugins. The second used git submodules. The third and current version initially used pathogen and currently uses Vundle.

While it started as my personal vim configuration and I still use it daily, it is definitely not “my vim” anymore, it belongs to the community and the hundreds of people who have improved it over the past 7 years.

My Vimrc file

spf13-vim enjoys a carefully crafted, organized and well commented .vimrc file. I’ve had a lot of people come up to me telling me that they don’t use spf13-vim or no longer use spf13-vim but have taken a lot of things from the spf13-vim .vimrc config file. Hearing this makes me really happy as the purpose of spf13-vim was always to make using Vim better.

I wanted to point out a few noteworthy things about the configuration:

It is broken up into sections with headers and folding. The general section takes care of a lot of the typical vim configurations while there is another section dedicated to customizing the UI.

Virtually every single setting has a comment explaining what it is doing. Here’s a few random lines from the file to convey this.

set tabpagemax=15               " Only show 15 tabs
set showmode                    " Display the current mode
set linespace=0                 " No extra spaces between rows
set smartcase                   " Case sensitive when uc present

spf13-vim changes very few of the vim default settings. It does this deliberately and also has an easy way to revert back to the defaults.

I remap leader to ‘,’ which is in a more convenient (and consistent) location.

I’ve never liked the way Vim navigates windows and tabs. I think that this comes as a result of these features being added much later. I should be clear, I think the settings are logical, but I don’t enjoy using them. It’s too many keystrokes for something I do super regularly.

Instead I remap window navigation to <ctrl-jklh>, which directly mirrors the cursor navigation.

map <C-J> <C-W>j<C-W>_
map <C-K> <C-W>k<C-W>_
map <C-L> <C-W>l<C-W>_
map <C-H> <C-W>h<C-W>_

I remap tab navigation to H and L (<shift-hl>) which works out quite well.

map <S-H> gT
map <S-L> gt

Again it mirrors the cursor and window navigation. As tabs are only horizontal, it has the benefit of not needing to touch J & K which already have very important and widely used default settings. It does change the defaults which are to jump the cursor to the top and bottom of the screen. I personally very rarely used these features and they made a lot of sense to me as I now used one mnemonic for all directional movement operations. I know this is a long explanation for one setting, but this same care was given to every single setting in the file, especially anything that changed a default behavior.

I also change a few other defaults to things which generally just work more like (I and) most people expect…

" Wrapped lines goes down/up to next row, rather than next line in file.
noremap j gj
noremap k gk

" Visual shifting (does not exit Visual mode)
vnoremap < <gv
vnoremap > >gv

" Allow using the repeat operator with a visual selection (!)
vnoremap . :normal .<CR>

" Easier horizontal scrolling
map zl zL
map zh zH

" Yank from the cursor to the end of the line, to be consistent with C and D.
nnoremap Y y$

I highly recommend people checkout the spf13-vim .vimrc file. It has a lot of neat tips in it and makes a great starting point when you want to customize your own vim.

ColorSchemes

spf13-vim uses the very popular color scheme solarized. It has been the default for spf13-vim for years. To be completely honest, I really like it, but after a few years, it’s gotten kinda old for me. I often switch it in my local file.. Another colorscheme I like is Tomorrow Night.

Plugins

spf13-vim contains a lot of plugins…. like a ton. Some people see this and think that spf13-vim is pretty heavy weight, this would be accurate if you enabled them all, but spf13-vim is designed to make it really easy to enable groups of plugins that fit your needs and style. spf13-vim introduces plugin bundles which can be enabled or disabled via a single configuration line.

if !exists('g:spf13_bundle_groups')
    let g:spf13_bundle_groups=['general', 'writing', 'neocomplcache', 'programming', 'php', 'ruby', 'python', 'javascript', 'html', 'misc',]
endif

Rather than talk about all of the plugins, I thought I would highlight a few of them that I feel aren’t very well know and I really appreciate.

Vim-Go

I write mostly in Go today. If it wasn’t for fatih’s vim-go plugin I would probably hate coding Go in Vim. Instead, I love it. It is probably the best language integration plugin I’ve used. Writing Go in Vim is a really awesome experience.

Writing

Reedes has made it his personal mission to make it amazing to edit prose in Vim. He has a series of plugins that all make it better to write in Vim. One I really like is reedes/vim-wordy which has a set of dictionaries that review your writing and highlight undesirable words. For example you can highlight and consequently eliminate passive words or weak words from your writing.

A special remap

The intial version of vi was designed on a keyboard with a pretty significantly different keyboard from those commonly used today. One notable difference was that the escape key wasn’t at the top left, but in a much more convenient location similar to the tab key on our keyboards today. Learning this made me appreciate the thoughtfullness that went into chosing that key, but also made me jealous of those using Vim on the old keyboards. I wanted to do something similar so I remapped the very convient and never used caps-lock key to esc. I do this outside of Vim using a couple mac applications.

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

I have found the best way to learn Vim is to dive in with both feet. Have vim completely replace your text editor for 3 weeks. 3 weeks is key, you need to commit for a full 3 weeks or it won’t work. The first few days are super frustrating. You will hate life as you watch your productivity crash. You’ll feel like a child unable to do even the most simpliest of things.

Into the second week you will begin to get to a place of reasonable competency. You will know enough of Vim’s commands to get around and do the things you need to. You’ll still use arrow keys and do things in less efficient ways, but overall you’ll be productive.

The third week is key. In the third week you begin to realize the power of Vim. You will start to use the much more powerful movement keys along with the modifiers. In the third week Vim starts helping you do what you want to do better than you could without Vim. It is in the third week you relize that you don’t want to go back to your old editor.

Another great resource for learning Vim is the vimtutor. vimtutor ships with most linux distributions as well as on the mac. Most people are not aware that this tutorial exists. The vimtutor provides an excellent introduction to using Vim all the way from hjkl to :wq.

I also like to play a game when using Vim. I like to play vim golf (solitaire). Yes, I am a huge nerd. I like to challenge myself to do something and then see the minimum number of keystrokes it takes me. This has taught me a bunch of new ways of working with Vim.

What have you been working on recently in Vim?

As I mentioned earlier, I’ve been pretty obsessed with Go for the past couple years. I’ve been working on a site generator in Go called Hugo which is the fasted site generator in the world currently. Many people that switch to Hugo from other generators like Jekyll, Octopress (jekyll underneath) and Pelican experience over 1000x faster rendering. Hugo also benefits from the easiest installation and getting started of any site generator and works seamlesslly on Windows, Mac, Linux and BSDs.

I also write my blog in Vim as well as documentation for my projects as well as contributing to the Docker projects.