Friday, September 16, 2011

Visual Studio 2010 + Resharper 6.0 + ViEmu + AutoHotKeys = Developer Bliss

I just got a new work machine. It's strictly for work, so my job paid for it. My boss helped me configure it and allowed me to get a few mods that make it even more bad-ass. It's a Lenovo ThinkPad W520 with 8gb of RAM, 500gb 7400 RPM HD, and he also got me a 128gb SSD drive that I plan to swap out for my main drive. It's already fast, but when I'm done with it all, it's gonna scream. :) Thanks Bob!!

My MacBook Pro is still the bee's knees, but it just wasn't cutting it for my day-to-day Windows programming solution. I'll absolutely be using it for all of my personal use and Ruby on Rails development. It has gigs of music, movies, and photos on it, along with my Quicken and lots of other personal documents and files. It will continue to be my Unix playground and I'm very excited to use it for just that... It has retired from the hustle & bustle of the daily grind, and plans to live the high-life now as a "personal computer". It's earned it!

During my transition to my new laptop, I was able to configure my development environment to be exactly how I wanted it. Since my new machine has 8gb of RAM, this allows me to trick my VS2010 environment out to the max without having to worry about slow downs. My biggest problem with Parallels was that I could only (safely) allocate 2gb of RAM to my Win7 VM. I had to disable the nice Aero / translucent theming, and lots of other goodness. Even after doing all of that it still came to a crawl whenever I'd be flying along with my coding. There were times when would literally just have to put my laptop down and walk away or else I would throw it against the wall. This new laptop should curb those impulses. :)

One of the main problems with switching to any new laptop is learning a new keyboard layout. This is especially important for programmers who rely heavily on hot keys, like CTRL, ALT, HOME, END, INS, DELETE, PGUP, PGDN, F[1-12] keys, and the 4 arrow keys. There is no real "standard" for these key locations, and it seems like every computer manufacturer has their own idea of where they "should" go. My personal opinion is that the Microsoft Ergonomic Keyboard 4000 nailed it! I actually own this keyboard and it has moved with me through a few different computers. The function keys were laid out perfectly; they were exactly where they were "should" be.

As you might imagine, it was a hard transition to move to the Mac and learn the key combinations. Especially since the mappings were even altered in order to pass through into Parallels. There was no DELETE key, no INSERT key, no HOME key, no END key, no PGUP, and no PGDN key!! I had to use a combination of other keys to get to those "functions" using Mac's 'fn' key (ie. the fun key). Even the function keys were different; for example I had to know that F[1-7] worked as expected, but F[8-12] required that I press the Mac's 'command' key. After 2 full years of learning these nuances and mastering the different key mappings, I'm now back to the beginning with a new layout of hot keys. Ugh!!

While I can't fully alleviate the pains of switching keyboard layouts again, I can take comfort in knowing that I'm a Vim junkie and Vim doesn't use most of the hotkeys for editing text.
  • [h] = {left arrow}
  • [j] = {down arrow}
  • [k] = {up arrow}
  • [l] = {right arrow}
  • [0] = {home}
  • [$] = {end}
  • [x] = {delete}
  • [ctrl+d] = {pg dn}
  • [ctrl+u] = {pg up}
  • ... and MUCH, much more!
I just needed to find a way to switch up my keyboard mappings to mimic the keyboard mappings of Vim. Luckily, someone has already thought of this!! There is a product out there called ViEmu that extends Visual Studio's text editor with all of the Vim goodness that I've so pains-takenly learned over the last year. I'm currently running an evaluation version of it, but I can already predict that I'll be forking over the $99 for a license very soon. It's simply genius! Thank you Symnum for this wonderful product. :)

Once I installed it, I had to re-enable my ReSharper keyboard mappings going to ReSharper - Options... - Visual Studio Integration - Keyboard Shortcuts and selected the 'Visual Studio scheme'. This allowed me to continue to use things like [ctrl+T], [ctrl+R+R], etc..). There are a few nuances that I need to work around, but in the grand scheme of it all, this is much more fluid than looking at my keyboard every 2 minutes for simple navigation. I'm loving it!

To help further keep my hands on the "home row", I found a post by another fellow-Vim'er by the name of Jean-Paul S. Boodhoo. Jean-Paul described how he used a tool called AutoHotKey to map various key combinations to be more "Vim-like". This way I don't have to use [ctrl+shift+alt+up] to move code up and down. The first three keys are easy (bottom right corner of every keyboard layout), but the [UP] key changes and takes my hand far off the home row. Instead AutoHotKey allowed me to map it to [ctrl+shift+alt+k]... Very Vim-savvy.

I finally feel comfortable writing code on my new laptop. Yesterday was a LOOOOONG day, because I was forcing the new layout onto myself and it slowed my coding down so much. I'm used to coding at the speed of thought, and felt crippled. With ViEmu and AutoHotKey both configured now, I'm flying. The last 2-3 hours have been simply painless.

Now if only Blogger had a Vim editor...


Michelle said...

You get a new computer and I am working on a hand me down; how's that work!? :D Now you have to work faster, hmmm?

Anonymous said...

Looks like we have a lot in common. I love R# + ViEmu combo, love AutoHotKey, have 2 MS 4000 keyboards and own a Lenowo W520 with an SSD, but mine has just 24 GB of RAM ;-P
Gotta search though your blog to see for some tips/tricks/tools/etc. that I might copy from you :)