Make your Vim a bit better: a simple but very useful vimrc

@ 2012-04-19 by João Paulo Pizani Flor

Since my second or third year in college I was already flirting with Vim, as if Vim was THAT girl - you know - the girl of my dreams: I admired it, I knew it could make my life happier and also less stressful. On the other hand, I knew Vim would require time, effort and commitment. So after some “one week stands”, last year I finally decided to commit to Vim. Well, even though the honeymoon is over, I’m still learning more about vim every day, and admiring it more and more.

Enough with the weird girlfriend metaphor, one of the first things that anyone seriously considering Vim should try to learn is how Vim’s configuration system works. Every single piece of customization for Vim is organized in simple plain text files, written in a simple but powerful language called Vimscript. A big part of the power and general awesomeness of Vim comes from the great deal of extensibility provided by Vim scripts (that’s how files written in the Vimscript language are known). In fact, there are hundreds (if not thousands) of useful plugins for Vim - along with some not so useful but still awesome ones.

I use lots of plugins and have them organized in a nice way, but that’s another post. Today, I want to start slowly and just show you what I use as my “basic” Vim configuration file - how my .vimrc looks like.

A file called .vimrc sitting on the user’s home directory is the main point where Vim looks for configuration directives upon startup. The file below is not exactly my whole .vimrc, but a big part of it (the plugin-independent part). There it goes:

Even though it might seem like this file does A LOT of things, still it can be summarized to some highlights:

With this configuration in place, I hope that Vim becomes even more of a pleasure for you to use - as it has been for me. There are no guarantees in life, however, and you might not like my key mappings, for example. In this case, PLEASE feel free to suit them to you liking. And, if you think you found some really interesting variation of my configs, please fork the above gist from GitHub (again - the link - and submit a pull request :)

EDIT: You’ll almost certainly need the latest version (7.3) of Vim to enjoy all the nice features I wrote about… If you use Linux and your distro doesn’t still include Vim 7.3 in the repositories, then you can download the sources (from here - and compile Vim yourself - It’s quite easy, really. In case you use Windows there’s also a nice installer in the same address above.

That’s all for now, folks! Soon I’ll post more about my greater Vim setup.