Eric is the Editorial Manager at DZone, Inc. Feel free to contact him at egenesky@dzone.com Eric has posted 804 posts at DZone. You can read more from them at their website. View Full User Profile

The Cleanest vimrc You’ll Ever See

01.23.2012
| 4677 views |
  • submit to reddit

So many of us use vimrc files that are a frankenstein’s monster, cobbled together from spare parts, gists, and snippets from wikis. One day I decided I was no longer going to treat my vimrc as a garbage dump. As programmers, we strive toward well factored code, so why do we accept such ugly vimrc’s that are impossible to understand, and even worse impossible to share because of their complexity. Let’s stop the insanity! It turns out it’s very easy…

This is a repost of a blog by Yan Pritzker

Since vim automatically loads everything in ~/.vim/plugin/, you can just add a directory like ~/.vim/plugin/settings and put each semantic piece in its own snippet. Put your keymaps in ~/.vim/plugin/settings/keymap.vim. Put your visual setup like font and colors into ~/.vim/plugin/settings/gui.vim, etc.

After I did this, I ended up with a vimrc that’s only about 90 lines long including very detailed comments about every section.

I think this is the cleanest vimrc you’ll see on the web. All my vim plugin settings are broken down into individual files, following a convention of one file per vim plugin that I use, plus some extra ones that are too small to be plugins.

Think your vimrc is better? Show me! I want to learn :)

My vimrc and the rest of my vim setup is available as part of my YADR (Yet Another Dotfiles Repo) project. Come check it out, I need alpha testers!

Published at DZone with permission of its author, Eric Genesky.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

John Jones III replied on Fri, 2012/02/03 - 1:46pm

AAaahhh!!!! It burns!!!! tooo.... readable!!!! /me runs off crying..

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.