This subject is covered very well by a document at the Linux Documentation Project. Please reference the C-editing-with-VIM-HOWTO.