How I

Daniel Schauenberg

Infrastructure toolsmith

Brooklyn, NY

Who are you and what do you use Vim for?

My name is Daniel and I’m a staff engineer at Etsy on the DevTools team. We are an infrastructure team that handles things like maintaining the deployment system and the development environment, the application level metrics stack, and dev data access. My daily work is a very fun mix of software engineering and operations type work.

Due to the nature of that I write a lot of Chef, shell scripts, ruby, and PHP. Outside of work I also write the occasional bit of Go or C++ for some of my open source projects. For all of this I always use vim, 99% of the time running inside a tmux session.

I got introduced to vim in 2004 by a friend who showed me around Linux and UNIX when we were both first semester university students. Back then I didn’t have a preferred editor and as I learned more about Linux I just used vim as it already was installed on most systems. I very quickly switched from Linux to FreeBSD and with that from vim to vi (or nvi rather) as the default installed editor. At that point I hadn’t really started using any plugins, so going from vanilla vim to vi wasn’t really a big deal for me. I used it long enough in that setup that when I got my first Mac and started using editors like SubEthaEdit, Textmate, and Smultron because I liked their native look and feel, I had already built up the vim muscle memory. And as I was using gVim on the Windows machines at work, I kept the muscle memory although I wasn’t using vim on my personal machines. When I went back to grad school I eventually switched to MacVim. Mostly because Textmate and all the other OS X editors seemed like abandon ware at the time. And I wanted something I was familiar with and I knew would stick around. So I decided to go back to vim and go full in with customizing it to my needs. And now roughly 7 years later vim is basically the only way I edit text files on a computer. I use it for code, blogging, journaling, meeting notes, emails (via mutt), and accounting (via ledger). I try to use as much of vanilla vim as possible as my job includes working on a bunch of different servers and I don’t want to be slowed down too much when I don’t have my vim config ready. I also try to only use plugins that are purely written in VimL. That way I don’t have to deal with how to build the right vim on the different platforms (OS X, Linux, FreeBSD) I’m most likely to use it on.

Sadly on the iPhone vim is not a super great choice so I use Editorial there, mostly for writing blog posts when I don’t want to have a laptop open.

Introduce us to your Vim config.

When I went back to vim I also started using plugins for real. While writing my undergrad thesis (with vim and latex) I had already started with a super simple vimrc file I found somewhere and that is still the base of the setup I use today - 9 years later. When I started adding plugins to my vim setup, some of the first ones I added were pathogen and fugitive. I also was used to having tab complete things so I installed supertab. From there I constantly added and removed some plugins and over the years I’ve converged to a dozen or so plugins that I have installed. I keep them together with my vimrc in a git repo on GitHub and I wrote a Makefile that handles installing the configuration via symlinks and updating and adding plugins via a vim-bundle script I found somewhere and have downloaded into my ~/bin. The plugins I use most are the ones that are just enabled in the background and do their thing, like syntastic, supertab, tabline, or syntax highlighters. I do have some others to add functionality, like ctrl-p, nerdtree, or VoOM. I do use them occasionally, but most of the time forget about them. A plugin that falls into that category but that I use a lot is vim-zenroom2. It creates a writeroom style focus in vim and I love it for writing. I use it a lot for blog posts, journaling, meeting notes, or documentation writing.

Another plugin I wrote and use a lot is vim-stencil. It provides a simple way to have templates for vim that you can load into a buffer. It’s inspired by the vim skeleton files and I use it a ton for meeting note templates, journaling scaffold and weekly planning notes. A nice side effect of writing emails in mutt is that I can also use it for canned responses. Plus I can keep all of my templates in git together with my vim config. The plugin also provides a very basic set of variable expansions for common things like date or weekday.

I use solarized light as my theme although I wasn’t a big fan when it came out. I used a slightly patched version of molokai for many years. But one day I realized that I was really annoyed by the different applications I use a lot in the terminal (regular terminal colors, vim, mut, weechat) all look different. And I wanted consistency and at the same time switch to a light theme as it was easier on my eyes. And solarized light was the only one people had already ported to most applications. So I gave it a real shot and now I really enjoy it.

Some of the maybe more interesting things in my vimrc is that I have line numbers turned off. I used them for a long time, then played with relative line numbers for a bit and then decided that I don’t really care about it most of the time, so I just turned it off. When I really want the current line number I just look in the statusline. I also have a lot of one off settings and inline functions in my vimrc. I have a Today() function that inserts the current date in a specific format and is mapped to ,d (, is my leader key). I use it a ton when writing my work journal or taking notes in meetings. I’ve also inlined the GoFormat function from the deprecated official plugin. They made vim-go the new official one and it did way too many things for my taste as I only really wanted automatic formatting for my Go code.

I also activate spelling for a certain set of file types. Funnily I still have it enabled for .tex files from my university days. But these days the setting to enable it for markdown and mail (as I use mutt) is what I really use. As those types of things are mostly read by others (email and documentation) and written in English which isn’t my first language.

Speaking of writing in vim. I use it a ton for non programming as well. And as mentioned I use vim-zenroom for focused writing which depends on Goyo. In order to make the experience better there I have some Goyo hooks in my vimrc to close the buffer if it’s the last one in Goyo mode and also run a command to disable the tmux status bar for complete focus.

I also have the arrow keys disabled to force me to use hjkl for navigation. I did that when I started at Etsy and knew I would be working in vim a lot more so I decided to train that muscle memory. A side effect of that is that I enable hjkl navigation support wherever possible in other apps.

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

I think the most helpful resources have been the vim wikia and random blog posts when I was researching some specific things like setups for writing or programming in specific languages.

When it comes to writing plugins, I think I learned the most from reading @tpope’s and @mattn’s code on GitHub.

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

I can’t remember what the most recent thing is, but something I want to learn is how to better navigate within text. I do use G, ctrl-d, and ctrl-u a lot for longer jumps. And I use O/o and A/a and those commands a lot when I know I want to insert things. However within textblocks or when in visual mode I still hold down hjkl until the cursor is where I want it to be. I would love to have a more ingrained understanding of how to jump more efficiently in vim.

How did you get started writing Vim plugins?

I think my first steps in plugin writing must have been around 2010 when I was trying to add mustache support to the zencoding vim plugin. I was just learning about the current state of web development and tried out a lot of things. I was really into mustache and the idea of writing HTML faster with zencoding intrigued me. I think I never actually got it working or I sent a pull request and it didn’t get merged and I failed to follow up. But it was super fun and I learned a lot.

Tell us about your plugin simplenote.vim.

simplenote.vim is a plugin that lets you edit and manage your simplenote notes right from vim. It really grew out of the situation that I was a big fan of simplenote and it was the only application I used for writing outside of vim. So I wanted to see if I couldn’t get it working as a vim plugin and not have to got the route via Dropbox syncing. It was really mostly a curiosity thing and something I thought would be cool to exist. My initial plan was to write it completely in vim script. As I me tokens before I really like having a vim setup that doesn’t need any special things compiled in. And I had a rough version working that used curl for talking to the API and presented JSON to edit. However when it came to JSON parsing all the existing solutions were not super intuitive and I needed to somehow make it easy to install the dependencies for the plugin as I wanted it to be really easy to use. And then I would still have to write all the API wrapper methods for the actual API. So I decided to just write a python module for the simplenote API and publish that as well. And make a strict separation between data access and storage which would be Python and vim interfacing which would be vim script. I chose Python at the time because I was already familiar with it and had written a bunch of API wrappers for different things in it already.

The first version was super barebones and pretty rough, but it was incredibly fun to write it. The hardest part was probably testing it as I had no idea how to write unit tests for the vim script part of the plugin. So it was a lot of editing, putting in echo statements, and opening another vim session to try it out. I learned a ton about vim’s buffer and window model, how to run concurrent Python inside my editor and how to manage a somewhat popular open source project.

After a couple of years of using it I stopped as I didn’t want to host my (at times pretty personal) notes on someone else’s computer. And as I couldn’t give the project the attention it deserved while not actively using it I reached out to @atomicules who had been the most active outside contributor at that point and asked him if he wanted to take over maintenance of the vim plugin and the Python module. Fortunately he was up for it and so for the last 3 years he has been doing a fantastic job of maintaining and pushing the project forward.

Are you involved in a local Vim community?

I’m not. For some reason that has never occurred to me.

Share a snippet of Vim script you’ve written and talk about what it does.

function! Today()
  let today = strftime("%A %m\/%d\/%Y")
  exe "normal a". today
command! Today :call Today()

This is the snippet I talked about earlier that inserts the current date after the cursor position. It’s pretty simple and yet incredibly useful for me. It creates a string from the current date formatted as “weekday day/month/year” and appends it at the current position. The function is then mapped to a command with the same name so I can call it as :Today and also map that command to a leader key combo.

What have you been working on recently in Vim?

I’m currently working on a bunch of infrastructure projects at work that mostly involve writing chef recipes or PHP. I also constantly use vim to update documentation and write emails.