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:
  • Build up a feasible Vim configuration structure so your vimrc, plugins, syntax files, ... are all manageable.
  • Putting your whole configuration in a version control system.
  • How you can access my (amazing) Vim configuration.

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:

  • MySys: What O/S are we on?
  • runtimepath: Source colors, plugins, doc etc.!
  • source: Source the main vimrc (i.e. the one that actually has a lot of configuration)

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

Runtimepath is really smart. Basically if you put ~/vim_local in your runtimepath Vim will search and source under following directories:

  • ~/vim_local/plugin/ - All your plugins
  • ~/vim_local/colors/ - All your color schemes
  • ~/vim_local/doc/ - All your docs
  • etc...

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:

  • svn add ~/vim_local/plugin/foo.vim
  • svn commit -m ""

Then on all my setups I can do:

  • svn update

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

The features:

  • 800 line commented vimrc
  • Beautiful color schemes
  • Useful plugins
  • Works on Mac OS X, Linux and Windows
  • Around 2 years of work
  • A lot of goodies
  • Works with Vim 6.3 and Vim 7

Color schemes included:

Plugins 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:

VIM Editor 12. Aug 2006
9 comments so far

Wow - thanks for the vimrc. Great article series, too. I've been a vim user for years, but never really took the time to customize my setup - now I can just tweak yours! :-)

Great that you like it matthew.

A caution for users that use my vim:

  • Arrow keys in normal mode are mapped, i.e. you have to use hjkl to move around. Down is mapped to delete buffer.
  • I use $ as a kick starter for parenthesis/bracket expanding. So $1 expands to (|), where | is the cursor. PHP or Perl users should probably remap those keys.
  • Try to press F9 :)

Hey the script is great. There is also another configuration called Cream and seems to be similar to your work.

I have changed my vimrc file for mac osx and i was using vim from macvim and the verson that the mac shiped with. this is causing confusion for me, a vimrc file was created (note the passive voice) and i dont know if eather vim is using it. your WMToggle command isn't recognized by either version. I would also like to change the default color shceme of the gvim and dont know where to start. If you could help me clear up this confusion it would be quite appcreciated, I just dont whant to mess with the origenal environmental variables.

I like this .vimrc:
http://www.dotfiles.com/files/9/53_.vimrc

I checked out your vim_local, but in my italian keyboard $ isn't a best chooice for escape character, how can I modify it in traditional ?

I checked out your vim_local, but in my italian keyboard $ isn't a best chooice for escape character, how can I modify it in traditional ESC ?

Thanks alot for these articles! I use vim on Windows (at the office) and on several linux distros at home and elsewhere. Using vimrc with subversion has been a brilliant improvement!

Keep up the good work!

:)

Great stuff! Thanks, I'm using it on linux, Mac OS X and Windows. I added this on line 119 of \vim_local\vimrc for windows:

elseif MySys() == "windows"
set gfn=Lucida_Console:h9:cANSI"

Post a comment
Commenting on this post has expired.
© 2000-2009 amix. Powered by Skeletonz.