Pages

The challenges of running Visual Studio on a Mac

In the week since I got my Mac Pro I have made a conscious effort to transfer everything that I knew I would need over from my Windows XP machine. I've even powered off the Windows XP machine - something I rarely do with a computer - because I wanted to make sure I didn't try to use it as a crutch. My goal was to see if I could really switch to Mac completely and one week in that has been the case, though there has been some compromise.

I use VMware Fusion to run Windows XP in a virtual machine. It works really well for the most part and when it is running in full screen mode I really feel I'm running a Windows machine, with a couple of major exceptions:

Keyboard Shortcuts: Visual Studio makes heavy use of function keys, especially for debugging. By default the critical ones I use most are F10 (Step Over) and F11 (Step Into) and F9 (Toggle Breakpoint). On my Mac's keyboard the F9 key advances the song/track in the player, F10 mutes the speaker and F11 lowers the volume - these are special feature keys for OS X and work in any application you happen to be in.
You can flip a toggle in the System Preferences to allow the Functions to operate as standard keys, in which case they will not work as special feature keys unless I hold down the fn key on my keyboard. Likewise if I have the option in System Preferences unchecked I need to hit fn in order to access the keys as standard F keys.

There was also one other layer of complexity added to all of this: by default OS X ships with some keyboard shortcuts of it's own that also conflict with things. This threw me for a little while because by default some of those F keys are mapped to Spaces and Expose.

What I ended up doing was eliminating the Spaces, Expose and Dashboard use of the F9 through F12 keys; I use the mouse for that stuff anyway. I also keep the option to use the special key feature enabled, meaning that if I want F10 to be passed down to my application I need to hold the fn key too. It's a pain in the ass but I really like having the special keys enabled. Too many functions for too few keys.

I really do wish the fn key was a toggle, not a modifier key though. That would make it so much easier. I spent a couple of hours researching how to make it work that way but had no luck.

Using the Keyboard to Navigate Text
I've mentioned before that the text navigation keys between Windows and Mac are different. On Windows you use Ctrl-Right, Ctrl-Left to move the cursor one word at a time to the right or left. On Mac it's Option-Right, Option-Left. Well, this creates a little conflict when using VMware Fusion and Visual Studio.

By default OS X uses Ctrl-Right to move to the Spaces window to the right, Ctrl-Left to the Spaces window to the left. As a big time Spaces user I've found this excellent, unfortunately I've had to disable the feature since I really need the ability to Ctrl-Right and Left arrow through words in Visual Studio. This is not something I'm terribly happy about but I'm trying to get used to it.

Other than these two issues, so far it's been excellent. My development performance has actually increased a bit because all of the applications I've come to count on are now on the Mac Pro.

24 comments:

Robert said...

Thank you very much for this post. This is exactly how I'll be using my Mac once I get it (that is: using it as a Mac with a virtual XP for Visual Studio purposes) so I'm really loving reading your problems and solutions in this blog. Keep updating us as to these issues. Your blog has been an uncanny find for me. I thought I'd have to discover all of this out for myself blind. Your accounts have been very educational and inspiring for me.

Eric said...

You could also invoke Spaces and Exposé via hot corners! (System prefs > Exposé & Spaces)

My favorite use of hot corners is dragging images from a web browser, pull it to a corner to show the desktop, and drop the image on the desktop

Charles said...

David, just a quick thought..... I appreciate that the Mac probably isnt going to be your development platform anytime soon.... but as you are a developer - have you considered spending your weekend(s) trying to write an application that will allow you to set up some rules for keyboard keys - based on current open applications ? (just thought it might be the perfect excuse to open up xcode - possibly with the help of helpful mac developer out there)?

Eric said...

Another tip!

You can scroll in other windows without changing window focus. Just hover your mouse over a background window and scroll! Very handy

Charles said...

You experience the exact same problem using a Java IDE on the Mac. I solved it by mapping the function keys to Ctrl-Option-Command-Fn. I haven't run into any application that uses all three keys together.

David Alison said...

@Robert: I'm really glad to hear that man! It's always good to know that the stuff you take the time to write down is helping someone else out.

@Eric: Losing the F keys for spaces really hasn't been an issue for me because I use the additional buttons on my mouse for that, but thanks for the tip! On the window scrolling, I use that all the time and love it. The only problem is when I move to my VM with Windows running it (obviously) doesn't work there. Argh!

@Charles: I've given some thought to spending time with Xcode, having played with it very briefly. I actually would just like to create a little utility or even a hack that would convert the fn key into a toggle instead of a modifier. The problem for me is that I'm already spending my weekends working on my core product (when I'm not working on this blog). Since I work out of my home office I have no excuse not to work. Someday perhaps...

hff135 said...

I'm a new Mac user also (just switched last week).

Last night, I had the same problem with Spaces interfering with my Ctl-right, etc. I just remapped Spaces to use Ctl-Option-arrow and now everything is better.

You can do this through the Spaces prefs.

David Alison said...

@hff135: Thanks man - didn't realize that you could use multiple modifiers in Spaces for the direction commands. I appreciate it!

VesperDEM said...

David, I wanted to let you know that you can also use the F16-F19 keys for Exposé instead of the default F9-F12. So long as you use the aluminum keyboard that came with the Mac Pro. I was so used to using the Fkeys to access exposé that I changed mine to F16-F19 in order to keep using them. F19 for Dashboard in case you are wondering what the 4th key is for.

When you say the fn key in not a toggle, I assume you are talking like the caps lock key. So that with the fn key in one mode, the media function keys and such work and when the fn key is in the other mode, the function keys work as normal function keys.

I suppose that would be nice, but if you really need the Fkeys to work as normal, I would suggest enabling that option in the keyboard preferences and just use the fn-Fkey combination to use the media keys when needed. That's what I would do if I were in Parallels more than OS X. I suppose if I get this job I am interviewing for, I'll probably be considering it since it would mean working more closely with Windows as well as Mac and Linux.

As always, great post!

David Alison said...

@VesperDEM: It's tough for me because I do see value in both sets of keys (the volume control and music management stuff especially), yet when debugging I gotta have them. Not that big of a deal I guess. Good luck with the job interview!

Chris Howard said...

Dave, have you tried Parallels yet? I can't say I'm familiar with VMware and I suspect there's not a lot of differences between the two.

However, Parallels does have some in-built keyboard remapping, although F-keys aren't among them. But you can simulate the Windows version of those keys from the menu. Also I did just see Windows has a virtual keyboard in the Accessories/Accessibility menu which I'm sure you already knew about.

Another feature I like of Parallels is it can assign in Windows and Mac which program to open files with. eg you could have all your PDFs, whether in Windows or Mac, open with Preview.

And it has the Coherence mode which sounds the same as Unity mode.

The latest MacUpdate promo bundle includes Parallels plus 9 other apps for only $65, which is $15 off the normal price for Parallels alone. (thos there's only one day left in that sale. http://www.mupromo.com/)

David Alison said...

@Chris: I haven't tried Parallels yet - though now that I've paid for VMware Fusion it's unlikely that I'll spend much time looking at them. As I find applications I really like I buy them and once that happens I do everything I can to make them work.

Zachary said...

David,

I don't have any experience programming for Mac OS X (yet!), but I would imagine it wouldn't be too hard to implement something like your fn toggle feature. Create an applescript (or some similar program) to check/uncheck the box you mentioned in System Preferences. Then map a keyboard shortcut to that script (maybe through Quicksilver?), and you have your toggle!

Richard said...

Thank you for this information.

I'm thinking about taking the leap myself but am dithering over hardware requirements.

Do you have any thoughts upon RAM requirements which would be appropriate for a Parallels setup (VS 2008 on the PC side)?
Thank you.

David Alison said...

@Richard: Hmmm - not too sure about running VS on a Mac w/ Parallels since I've only used VMware Fusion. My recommendation on Fusion is to get at least 4GB of RAM. You don't really need it but it allows you to dedicate 2GB to your Windows VM, which minimizes thrashing because of having to drop into virtual swap space. One of the advantages that Fusion has over Parallels is also the ability to take advantage of multiple cores, allowing you to have two available for Windows if you happen to have several available to the OS.

On the memory front keep in mind that the stuff is really cheap. I paid $97 for 4GB of memory for my MacBook and the price has dropped quite a bit in 3 months. My belief is that there's no such thing as too much memory.

Arne said...

You could have solved both the Exposé and Spaces problems by disabling Mac OS keyboard shortcuts in the VMWare Fusion preferences. This is the way I do it on my new MacBook Pro, e.g. while Fusion has grabbed the input, Ctrl-Left moves the cursor as expected, but when Fusion has not grabbed the input, for instance because another application has the focus, Ctrl-Left goes to the previous space. There's no need to turn these shortcuts off entirely.

The only downside is that you have to release the input from the VM in order to switch to another application, i.e. instead of Cmd-Tab, you press Cmd-Option followed by Cmd-Tab. Likewise for Spaces but that was the entire point, right?

By the way, on keyboards which do not have dedicated Home, End, Page Up and Page Down keys, for example on the MacBook Pro, you can use fn-Arrow instead in the VM. fn-Left is Home, fn-Up is Page Up etc.

And I happened to try Parallels, but on my VT-enabled Mac mini, VMWare Fusion delivered 3 times the single-threaded CPU performance, plus it supports two virtual processors as was already mentioned. In my opinion, Parallels may be ok for casual users or the ones who just want to run their Windows-based office apps, but Fusion really blows Parallels out of the water when it comes to more demanding applications.

Neil H said...

To spark the parallels vs fusion debate.. I've used both and find parallels to be a poor choice in comparison. It is slower and doesn't have some of the nice features that fusion has like spanning multiple monitors.

Anonymous said...

You might as well get rid of Visual Studio now, because with a Mac, all you're going to end up doing is dicking around and blogging about how much you like using your Mac. Oh wait a minute...

David Alison said...

@Anon: Such a comedian! I ended up moving away from Visual Studio and .NET in general and went with Ruby on Rails to build SharedStatus. Much happier that way.

Anonymous said...

You say disable spaces etc.. or disable in vmware... I can't find what your talking about. can you give instructions on how to do this?

iPad Mini Adaptor said...

it was awesome!!

DavidBarrows said...

Several years later, your post is still pertinent. This was exactly the issue I was having; trying to debug in Visual Studio, which requires heavy use of F10, F11 etc. Clicking the check box under keyboard preferences in the Mac OS was the answer. Many thanks for this tip.

David Alison said...

@DavidBarrows - excellent, glad it helped!

adevelopersnotes said...

I really need the ability to Ctrl-Right and Left arrow through words in Visual Studio too! How do I disable the "spaces" behavior in Yosemite?