First month of Vim

I’ve recently made the upgrade from the wonderful Mac text editor Textmate to Vim (in the form of MacVim).  What initially led me away was a hope to be able to run SPSS syntax from within Vim, which would allow me to avoid SPSS 16′s abysmal syntax editor.  While this turned out not to work quite as easily as I had hoped, and is still a bit broken (a post for another time), I learned quite a bit about Vim’s scripting language.  Seeing how easily extensible Vim was, I decided to make the switch full time.  I downloaded a copy of MacVim and started creating my .vimrc.

The first thing I did was create an easy way to update my Git repositories when I was finished editing them.  This turned out to be ridiculously simple. Just put this in your .vimrc:

command -nargs=+ Commit :!git commit -a -m "<args>"; git push</args>

creates a new command in Command mode called “Commit”. So if you hit “:” to switch to Command Mode in vim, and type:

Commit Version 0.96 Updated XXX to do XXX, fixed bugs in XXX

and hit return, it will commit the changes to the repository and then push the code for you. This makes it effortless to keep your repositories up to date from within Vim.

I’m still retraining myself to navigate around the document using the shortcut keys. The shortcut keys, when I am in the mood where I actually use them instead of arrowing around, sped up my code development greatly. Also, being able to run terminal commands from within Vim has provided me with countless new ways of interacting with my code. I’d highly recommend everyone spend a month or so using Vim. The learning curve is a bit harsh at first, but the payoff is fantastic.

Here is what my MacVim looks like:

More Vim tips to come, along with some zsh tips and the SPSS/Vim bridge.

Post to Twitter Post to Digg Post to Facebook Post to Reddit

This entry was posted in Coding Tips and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>