Wednesday, December 3, 2008

View Code Without Right Clicking

Here's a little Visual Studio 2008 tip for you. I find myself right-clicking ASCX/ASPX files and selecting "View Code" frequently during the day and today I just had enough of it. So I went a hunting on the Googley internet and didn't find much of anything useful (mostly just hints on using F7 and Shift-F7 to switch between Code View and Design View, i.e. not what I was after).

Using the search box in the Visual Studio Keyboard options to narrow down the list I found this little gem (click the image to see the full size version). Just select "OtherContextMenus.SchemaExplorer.ViewCode" and assigned it to your hotkey of choice. I used F12 F1 but I may change this later on if I find it too cumbersome. Don't forget to hit the "Assign" button or nothing will happen.

So now when I'm editing the front-end code and want to get to the back end code I just whack the old F12 F1 key and voila!

EDIT: Dammit, I just realised that F12 is the hot key to go to a method's definition so I'm now giving F1 a go seeing as I never use the inbuilt help. You can get your answer via a Google search before the inbuilt MSDN help has even loaded.

EDIT: If you accidentally assigned F12 to View Code you can set it back to its original setting by assigning it back to Edit.GoToDefinition in the Keyboard settings.

No comments: