Yan Pritzker photographer, entrepreneur, software engineer, musician, skier

Blog :: Git Workflows Book :: Dotfiles :: Photography :: About Me

TwitterCounter for @skwp

Get the news feed
Get updates by email
Follow me on twitter

hello, i'm yan

I am a photographer, entrepreneur, software engineer, guitarist, climber, and telemark skier

This blog is about startups, blogging, Ruby On Rails, virtualization and cloud computing, photography, customer service, marketing, ux and design, git, and lots more.

Enterprise intelligence with prediction markets

Find out what your team, colleagues and partners really know about the future — and leverage their knowledge to improve business decisions.

I'm the founder of Planypus, the place to share your plans!

Archives

Contact

Reach me at yan at pritzker.ws

The cleanest vimrc you’ll ever see

Posted 20 January 2012 @ 12pm | Tagged vim


Submit to HN

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…

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!


19 Comments

Posted by
Jay Graves
20 January 2012 @ 12pm

Very timely. Just this week I gave myself a TODO so my various VIM configs (work windows, work linux, home windows, home linux) were in sync.

But I stated it: “Startover with VIM”

I’ll check it out.


Posted by
Apreche
20 January 2012 @ 1pm

My vimrc is definitely cleaner than yours.

https://github.com/Apreche/vim/blob/master/vimrc

The real answer to making your vimrc cleaner is to stop using all those customizations. You don’t need them. If you haven’t become a complete master of all the defaults of vim, then you don’t need to add more features you don’t need anyway.

The only things I change are fonts, syntax highlighting, colors, indentation, and not much else.


Posted by
Kristian
20 January 2012 @ 2pm

Are you guys really jerking off over who has a better vimrc file? Get a hotel room already.


Posted by
Tony
20 January 2012 @ 3pm

One thing you do have kind of wrong in there is your guard around undofile and undodir – these setting are not dependent upon the GUI or MacVim, they are new features in Vim 7.3, so your guard should be:

if version >= 703


Posted by
Yan
20 January 2012 @ 3pm

@Tony thanks! an example of something I did early in my vim experimentations without bothering to learn. Will fix this.


Posted by
Chris Smith
20 January 2012 @ 4pm

Mine goes:

syntax on
colorscheme blue

That is it. There is no ~/.vim


Posted by
Chris
20 January 2012 @ 4pm

I spent a fair amount of time on my vim config, and tried to organize it into something to share with a few folks: http://github.com/csexton/viceroy

I am all for knowing the default vim, but it’s vim — the true power is being able to make it do what you want. Even Bram talks about how bloated his vimrc is.


Posted by
Eric
20 January 2012 @ 5pm

Yan,

I’m a community curator at DZone.com, and I recently read your blog post entitled “The cleanest vimrc you’ll ever see.” I was impressed by the quality of your writing, as well as the healthy response from your commenters. At DZone.com, we post quality content for the benefit of our community, as well as providing some much deserved exposure for good bloggers.

May I have permission to republish your blog post titled “The cleanest vimrc you’ll ever see”?

Shoot me an email if you’re interested.

Best,

Eric


Posted by
Yan
20 January 2012 @ 8pm

@Chris – viceroy looks interesting, I’ll take a peek and see what learnings may come. Looks a bit Janus-y in the way it handles bundles with a config file. I decided that I was going to use git submodules and not worry about having a config file, to keep things simpler, but there are probably tradeoffs on both sides.

The nice thing with a config-less approach is that if I want to try out a cool vim plugin I see on git, I just run a command like “yav -u http://github.com/foo/some-vim-plugin” and I have that plugin downloaded.

@Eric that sounds great. I will email you.


Posted by
Chris
20 January 2012 @ 8pm

@Yan It is a bit Janus like, but there were some things I really disagreed with in Janus so I rolled my own. Not that Janus is bad or anything, I just wanted something different.


Posted by
yan
20 January 2012 @ 8pm

@Chris that’s why I started doing the YADR project as well. Janus felt a little overcomplicated, and it didn’t really have the best plugins by default either. In addition to removing the idea of config files, I’m also being very strict in what it will support (i.e. only one color scheme, and only MacVim, and ensuring that every plugin I add looks good in that color scheme). I think once more people are forking it, it will become tempting to add support for other things, but I’m going to try to stay strong and opinionated to ensure that the core of the product works well. That said, I am always looking to learn from other projects and I’m going to have a look at your viceroy :)


Posted by
Igor
21 January 2012 @ 3am

You should give Sublime Text 2 a try :) It’s pretty hot.


Posted by
yan
21 January 2012 @ 3am

@Igor sublime is pretty…and it has some nice features. one of my friends at work uses it. but I can’t say it will replace vim for me because of the overall keystroke savings I get from vim


Posted by
sunaku
21 January 2012 @ 2pm

Hey, I thought *mine* was the cleanest of them all:

” delegate configuration to files in config/
runtime! config/**/*.vim

As you can see, it’s [not a single giant vimrc file](https://github.com/sunaku/.vim#readme)!


Posted by
sunaku
21 January 2012 @ 3pm

Nice tip about ~/.vim/plugin/**/*.vim being autoloaded on startup. I followed suit and replaced “runtime! config/**/*.vim” in my vimrc with nothing. Cheers.


Posted by
Matael
21 January 2012 @ 3pm

Mine is only… 8 lines long… And vim does exactly what I need :

syntax on
filetype plugin indent on
au BufNewFile,BufRead *.pde setf arduino
au BufNewFile,BufRead *.mkd setf mkd

set statusline=%F%m%r%h%w\ %{fugitive#statusline()}\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
set laststatus=2


Posted by
richard bucker
21 January 2012 @ 6pm

In theory I really like your approach to you vim layout. It has a certain elegance that I really like. Now I know you heard me say that I like it and I do not want to detract from that… however (aka but), since you installed NERDTree and possibly other plugins that have certain dependencies I start to get a little scrambled. Your approach could be seriously improved if there were a GEM or PEAK like installer that would install the dependencies. And while I’m on the RUBY thing I hope your plugins that depend on RUBY are capable of running within RVM.

Other than that, really nice work.


Posted by
Matt
31 January 2012 @ 1pm

Well, I thought mine was pretty darn clean…

https://github.com/mattdbridges/dotfiles/blob/master/vim/vimrc


Posted by
Matt
31 January 2012 @ 6pm


Leave a Comment