OK, first take a deep breath and repeat after me, “Jeff is not asking me to give up Visual Studio.”
Far from it. Visual Studio is without question the most productive environment for developing for Windows.
When everything is going well it functions like your little robotic code-monkey assistant. Memorizing a million API calls and settings is dumb. They will change. Your little robo-minion, however, has those APIs hardwired into his mechano-simian brain. Start typing and he will start suggesting possible matches.
So, relax, sip some nice, calming herbal tea and rest-assured that I'm not asking you to give anything up. Prying things from your cold, dead hands will not be required.
Having said that, [click] you have to admit [click, click] that Visual Studio [click] sure does make you [click] reach for the mouse WAY too often [click, click, clickety-click].
It also displaces memory the way the Titanic displaced water. It also occasionally behaves like the Titanic in a very crash and sink way.
Sometimes you need something light, fast and simple. In true “pick any two” fashion, you can try Vim. It is light and fast. It sure as heck isn't simple.
OK, I'll admit it, it's a tough sale.
On one hand you have the aforementioned all-singing, all-dancing robot-monkey vs. what appears at first glance to be a dead monkey.
Don't be fooled. THAT MONKEY IS NOT DEAD.
You don't see that in print very often. That makes me sad.
What's So Great About Vim?Let's start with the obligatory Top-n List.
Top 5 Things I Like About Vim
- Runs anywhere
- Keep hands on the keyboard
- Macros become easy and wildly useful (not at first!)
This was why I decided to take a deeper look at Vim. I find the frequency with which I have to reach for the mouse in Visual Studio distracting. Downright annoying.
You may already know that you can move around using home-row keys instead of those distant arrow keys, but what you don't know is that after a few days that won't be moving one character at a time as often as you will be leaping around.
The richness of text navigation options in Vim is a great strength.
You can jump to:
- Start/End of word
- Start/End of line
- Start/End of document
- Start/End of tag (opening or closing curly-brace for instance)
- Start to specific text
- Start to text specified by regular expression
- More and More and More
Remember the mention of macros?
Once you get in the flow of navigating your code in this manner, then creating macros becomes trivial. Literally 2 keys and you are recording a macro. Two more and you play it back.
So What Now?First things first, do this:
- Install Vim
- Open it
- Shut it down
- Laugh at me for suggesting you look at this crap!
Start With Derek Wyatt's ScreencastsDerek Wyatt made a series of screencasts a few years back that are found on his blog.
Derek is very funny and full of energy and enthusiasm for Vim. Watch his Novice and Intermediate level videos to get an idea of why you might care about Vim.
Move On To VimCasts.OrgDrew Neil put together a great series of tutorials as well over at VimCasts.org. Drew's videos are typically short and sharply focused.
Who Is Hosting This12/11/2016 Update! A new resource you might want to check out is Vi Introduction and Resources from Who Is Hosting This.
Decide If Vim Is For YouOnce you've watched some videos from Derek and Drew, you should have a good idea whether you want to pursue delving into Vim.
You might not. That's OK.
Some of you might.
For me, it isn't an either/or question. I use Vim with Visual Studio.
Options For Integrating With Visual Studio
- Keep them separate. Use Vim occasionally as needed.
- Install Visual Studio plug-in:
- Make Vim an External Tool
In much the same way, I try to avoid putting too many plug-ins into Visual Studio. Bare weight right now for me without a project loaded is around ~90 MB. Once I load a project, it will go way, way up.
For that reason, I have opted for the “Make Vim an External Tool” approach.
I have my F-1 key mapped to launch Vim (well GVim, actually) with the current document open at the current line I'm editing. I even have a Vim plug-in for working with Team Foundation Server.
For details on how to set this up (plus more), check out Integrate gvim with Visual Studio over at the Vim Wiki.
SummaryI can't say if you will like Vim. I'm guessing 90% of you will not.
I also can't say if a year from now I will be using Vim heavily.
I consider my current set up to be an experiment. For some things Visual Studio is perfect. For some things Vim is perfect. Neither is perfect for everything.
As long as I have to SSH into a server and edit files, I will use Vim or Vi to some extent. Now I will use it far more effectively.
##Update Here's a newer post on working with Vim: Stop Vim From Crapping In My Directories