Visual studio custom short cut hot key mapping
March 1st, 2009
My first post in 2009. Took only 2 months into the year. Sigh! There goes my resolution. On the positive side, it is a technical post. Been a while since I posted one of these.
Anyways, let’s get to the point.
So in the current project I’m working on, I build SharePoint web parts. A lot of them. As with typical SharePoint projects, the web parts need to be deployed to the GAC/assembly. before they can be added to the pages.
The problem with this as you can imagine, is that every change no matter how small or big it is, needs to be built and the assembly copied to the GAC (C:\Windows\assembly). If you are using the WSPBuilder Visual Studio plugin, this is probably a bit less cumbersome than going to the location of the DLL and manually copying it and pasting it in the assembly folder, you know, using good old Windows Explorer.
This is great if you are big fan of the mouse. Just 4 clicks/gestures. One for the build. And 3 for the GAC deployment – Right click on the project, Click on WSPBuilder, Select Copy to GAC.
But for people like me, that prefer keyboard short cuts over mouse clicks, here’s how we can make this much faster – Map custom short cut keys to do the build and deploy.
You may already know that Ctrl + Shift + B builds the project. But it builds not just the current project but every other project related to it (and may be even the independent ones too if I’m right).
Now that is still 3 keys. Let’s see if we can bring it down to 2 keys.
Here we go.
- Click on Tools – Customize in Visual studio as shown below.
2. Click on Keyboard
3. We need to find “Build.BuildSelection” command. So start typing that in the “Show commands containing” textbox. It’s autocomplete as you can see below. So just select the item as soon as it shows up.
4. After you select it from the list, move your cursor to the “Press shortcut keys” textbox below and press the short cut keys. I chose Shift + F1 since I just have to use my left hand fingers and the keys aren’t too far apart.
Note that you CANNOT type your shortcut. You HAVE to press the keys on your keyboard as the text above the textbox says.
5. After you select your short cut, the “Assign” button gets enabled as shown below. Click on that to assign the short cut to “Build.BuildSelection”. “Assign” button now becomes “Remove”. It took it. Good.
6. Now click OK.
7. Test the short cut now. Open up a file in a project and use your short cut. If everything worked ok, the project that file belonged to, would have been built. Just that project.
8. Wash. Rinse. Repeat. Do the same for “Copy To GAC” feature.
9. Look for “copytogac” in the commands text and you may notice that once you select the command as shown below, there already might exist a short cut for it. In this case it is Ctrl + Shift + Alt + B.
I don’t know about you but that is lot of keys to press for a simple command. It is ok though. You can leave it alone and map yet another short cut to the same command.
I chose Shift + F2.
10. Click Assign and then OK. And all done! Now we can easily build and deploy the currrent web part/dll to the GAC with the press of just 2 keys per command.
Shift + F1 to build. Shift + F2 to deploy to GAC.
I suppose it must save some amount of time in the long term. Enjoy!








Leave a Reply