Taming your Vim config - Vim tip 3 of 3
On a weekly basis I switch between 6 different setups and I alter in my .vimrc quite often. I would lose a lot of time if I manually managed my configuration. In this tip I will tell you how to:
Notice: When I write ~/ it means C:Documents and SettingsYourUser on Windows.
Building a configuration structure
I hope you know what a vimrc file is, if you don't read about it here.
My current vimrc looks like this:
fun! MySys() return "windows" endfun set runtimepath=~/vim_local,$VIMRUNTIME source ~/vim_local/vimrc
What, 4 lines? Jea, it's only initialization file that sets following:
Why is this smart? Because you can then share the same vimrc on all platforms, i.e. when updating your vimrc you don't have to set that you're on window, unix or mac.
Runtimepath is really smart. Basically if you put ~/vim_local in your runtimepath Vim will search and source under following directories:
Version control system
Use a version control system, if you use Vim on different computers. It saves a lot of time.
I am using SVN to manage my ~/vim_local/ directory. Basically, if I add a new plugin I do following:
Then on all my setups I can do:
And bam, I get that plugin. The same goes if I add some new clever mapping in my vimrc. The other approach would be to manually edit in all 6 configurations (I have tried this, believe me, you will have 6 different Vim configurations :-D)
My KICK ASS Vim configuration
Color schemes included:
Please, click on the links to read about what the plugins do.
How to get it?
First check out to ~/vim_local:
mkdir ~/vim_local svn co svn://orangoo.com/vim ~/vim_local
Next update your vimrc:
map ½ $ imap ½ $ vmap ½ $ cmap ½ $ "Can be: linux, mac, windows fun! MySys() return "unix" endfun set runtimepath=~/vim_local,$VIMRUNTIME source ~/vim_local/vimrc
½ is the key bellow ESC (at least on my danish keyboard). It's pretty crucial that you map this key to $. I use it often in my mappings.
Read it online
I have updated my vimrc and you can read it online:
12. Aug 2006 • VIM Editor