My awesome vimrc: open-source libraries + ctags = Intellisense + 1 for Linux
One of my coworkers at OSC asked me for my deck vimrc today and since I had to write up how to use it for him, I’ve decided to unleash my secret upon the world. Okay, it’s not that dramatic, but I think my vimrc is pretty good.
What is a vimrc?
A ‘vimrc’ is the configuration file for Vim, the world’s best text/source code editor; this file stores all your settings, customizations, etc. I started this while at Microsoft over the summer, basing it heavily off of Amir Salihefendic’s vimrc. He also extolled the benefits of having your .vimrc under version control; it seems crazy but it’s actually a great idea, only because it gives you a consistent environment even when you’re moving from machine to machine; ie, you make one change then just svn up to make it appear everywhere.
How do I get it?
svn co svn://svn.paulbetts.org/vimrc .vim
rm -f .vimrc .ctags
mkdir Repos tags
touch ~/.vimrc_local
ln -s ~/.vim/ctags ~/.ctags && ln -s ~/.vim/vimrc ~/.vimrc
ln -s ~/.vim/ctags_to_file ~/Repos/
ln -s ~/.vim/generate_tags.rb ~/Repos/
ln -s ~/.vim/rebuild_tags ~/Repos/
ln -s ~/.vim/sort-tags ~/Repos/
#### Only if you’re running Ubuntu Dapper/Edgy 32-bit x86! ####
# This installs the version of ctags that has extra
# annotations in it for Vim 7.0
cd .vim
sudo dpkg -i *.deb
Check the Tilde’s! For some reason, the font doesn’t always show the Tilde(~) very well; copy and paste the text to a separate window
What is all this ‘Repos’ business?
Here’s how it works: you’ll end up with two directories, a “Repos” directory and a “tags” directory. Since everything in Linux is open-source, the best way to do development is with the sources to the libraries you’re using (and the libraries they use!)
When you’re writing code, store the source trees of all the public libraries you’re using in Repos, like GTK+ or Qt. An easy way on Ubuntu is to run apt-get source name-of-package. Then, run ~/Repos/rebuild_tags; it’ll build ctags files for all of the directories in this folder and put the sorted results in ~/tags. It’ll also write out a file labeled ~/.vimrc_local which will tell Vim about it.
Fancy Omni-complete/Intellisense type tricks
Try pressing C-] (That’s Ctrl-] for you Windows folks) while you’re coding to instantly go to the reference, then hit C-Tab and C-S-Tab to go back and forth through the matches. Also, this enables ‘->’ and ‘.’ to do the Intellitype thing as well as making Tab do auto-complete, like in Windows.
Et cetera
There’s a lot of custom mappings, but they don’t really replace the real ones, only add extras. Check ~/.vimrc for the details. It also includes the MONACO.TTF font that I use, which is pretty good for programming in my opinion. Look through the plugins too, there’s a lot of stuff I’m missing!
Update: Intellitype is the MS keyboard technology. Damn it.