Porn, Zen, and .vimrc

Vim is a customizable text editor geared towards writing code. But open-ended configuration possibilities lure users into wasting time while chasing after perceived minute gains in productivity. This article describes my Vim journey, starting from heavy personal customization and ending with a renewed love for defaults.

Porn

As a rule, new users, right after learning a few basic commands, start indulging in Vim configuration porn. Such porn has various different flavours. There is the “exhibitionist” variety which includes dressing Vim up in status lines, colorschemes, and font decorations in order to impress others. It often leads to Vim being displayed on videos and, nomen omen, “vim-porn” screenshots. There is an “integrated” category where people plug and stretch their Vim until it resembles an IDE. Git integration, autocompletion, language servers, and refactoring are the tools of trade in this version. And then there are a few more variants, including “fuzzy”, “packaged”, “conveniently re-mapped”, and I am sure anyone could think up some of their own.

My particular genre was “consistency” - I wanted Vim to be intuitive and predictable. While working I would constantly keep an eye for digressions in Vim’s behaviour and then spend my time trying to adjust them. In my fantasy Vim had to feel intuitive and smooth so I tried to correct every little detail. And, despite “consistency” porn being quite vanilla, I managed to construct a vimrc file exceeding one thousand lines of code.

No point in sharing the entire collection, but here are a few illustrative examples and the rationale behind them. Feel free to try them out, if that is your thing.

A fresh start

So, no more vimrc. It did feel sloppy, at first. But I quickly found a new way to get around.

Some of the issues with highly customized configuration files are known to everyone. You have to use a plugin to manage your plugins; have to transfer dotfiles across different servers; lose the ability to work on machines without your configuration files; others cannot use your computer without disabling your setup first. Removing the heavy configuration got rid of those downsides. But I also experienced a few additional less talked about benefits which are listed below.

Zen

So, after all the trouble, do I have regrets about deleting my thousand line creation? No. The simple truth was that, no matter how much energy I invested in my custom configuration, the people who built and designed Vim knew it better than I did. Implemented defaults and design was there for a reason. Some of my perceived inconsistencies were products of my limited understanding. I made assumptions about what a particular command should do, when it should be used, and how. But those assumptions were not always warranted.

For a brief period I even went into the opposite direction and tried to make my vimrc as minimalistic as possible. This was an exercise in asceticism and it produced a similar negative effect, except in another direction. I still cared too much about my vimrc, only this time, instead of making it more consistent, I was striving to make it as light as possible. A similar paradox happens in some Zen practices where a disciple, being told he shouldn’t attach to things, starts attaching to non-attachment. The correct attitude, at least in the case of Vim, is to let go of the need for control. I learned to trust the choices of people who created Vim and to not interfere with their design. In the long run this attitude saved me from an uphill battle between me and my vim configuration. In the long run it helped me stop wasting my time.

Now, after all the struggle, my vimrc is around 50 lines in length. It only includes simple and frequently used commands, like this map to toggle search highlighting with ctrl-/ :

nnoremap <silent> <c-_> :set hlsearch!<cr>

Various boilerplate procedures that I previously couldn’t live without remain deleted. This includes things like setting relative numbers or opening a :terminal buffer. I started to look at those commands as a sort of a ritual that I have to perform before editing. It takes a couple of seconds but it gets me in the mood for work.

Thanks to /u/-romainl-, /u/dutch_gecko, and /u/htranix from /r/vim reddit thread for corrections.


  1. n and N remap answer on vi.stackexchange  ↩︎
  2. ; and , remap answer on reddit  ↩︎
  3. “vim–you–keep–using–that–word” plugin by Aristotle Pagaltzis on GitHub  ↩︎
  4. “vim–operator–replace” plugin by Kana on GitHub  ↩︎