6 handy visual studio keyboard shortcuts

Some times (often on a Monday morning while I’m warming up for the workweek) I feel like sharpening my Visual Studio skills.  I found this wonderful stack overflow question about VS keyboard shortcuts.

These three I’m looking forward to adding to my bag ‘o tricks.

3. Collapse/Uncollapse Current Block – CTRL + M

I’m always looking for ways to break down big files!

2. Attach to process – CTRL + ALT + P

If you’re a web dev, you probably do a fair amount of your debugging via attach to process.  Strangely, visual studio doesn’t list the attach shortcut next to the menu command.  So I guess it was a secret.  But now we know.

1. Cycle through open tabs and windows – CTRL + TAB

I can’t believe I didn’t think to try this.  It’s pretty common for my workspace to fill up with 30+ tabs.  Even more common is for all the visual studio widgets and gizmos to find their way into unexpected places.  This shortcut could save me serious time mousing around through the labyrinth of  visual studio menus.

Three that I currently use a lot:

 

3. Find in files – CTRL + SHIFT + F

This is such an important capability that I hope everyone is using in some form.  My most common usage scenario is when I’m given some kind of error like a logged exception or some javascript error message and need to figure out where it’s originating from.  Just search for a similar string in all your source files.  Common sense, right?

2. Back and forth through your cursor history – CTRL + ” – ” and CTRL + SHIFT + ” – “

If you’re frequently switching between files e.g. unit tests, business logic, display code for a feature you can use this feature to navigate between the files you’ve been working on without using the mouse.  It’s one of those features that will quickly become second nature.

1. Rapid file open – CTRL + SHIFT + A  followed by typing “open [filename]”

I didn’t see this in the SO post, but it’s the shortcut I’m most thankful for.  If you are working in a solution with thousands of files, hundreds of folders, and dozens of projects it can be tedious to navigate through the solution explorer to find a certain file.  Here’s where the console comes to the rescue.  When you use this keyboard combo, the console will either find the file you’re looking for or bring up a list of matches.

Rapid Fail Protection Fail

Somewhere along the way, IIS decided it would be a good idea to save developers from the uncertainty of a worker process that was constantly crashing.  So, the benevolent developers at Microsoft instituted something called Rapid Fail Protection that would automatically disable the Application Pool if your worker process crashed more than 5 times in a 5 minute period.  This is totally reasonable if your load balancer is smart enough to stop sending traffic to a server with a failed App Pool.  But, if you’re hosting your servers in Azure, the Load Balancer is currently not capable of this.  So, if your server borks a few too many times, your site visitors will be greeted with a lovely 503 error until an admin manually restarts the pool.

I’d personally rather monitor my instances myself for problems, than have IIS decide to pull the plug at 3am because there are 6 crashes in a 5 minute period.  Here’s how to disable it in Azure:

1. Set up a startup task.  Here’s a good intro.  Don’t forget to write the script in a non Visual Studio editor.

2.  Put this in the script

%systemroot%system32inetsrvappcmd.exe set config -section:applicationPools -applicationPoolDefaults.failure.rapidFailProtection:"false" /commit:apphost