Go to content
18 October 2013

Quick preview and edit code in Visual Studio 2013

I just wanted to do a quick post about one of the new features that comes with Visual Studio 2013 - in case you missed it.

If you are a fan of the Go To Definition (F12) command in Visual Studio, then you are going to like the new Peek Definition (Alt+F12) command in Visual Studio 2013. With Peek Definition you don't need to leave your current code context to view and edit the definition of another class, method, property, constructor etc. in a new code window. Peek Definition will inject the definition code window on the line after your current cursor position, making it a bit easier/quicker to understand the code logic.

Quick example using Peek Definition in Visual Studio

Here's a sample project where the main method is using another method, GetRandom(), and outputs the returned content.

Sample code

If we wanted to view the definition in the GetRandom() method, we could set the cursor on that method and hit F12 to trigger the Go To Definition command and view the code in a new code window.

Sample new code window 

Going back to before we hit F12 - if we hit Alt+F12 instead, to trigger the Peek Definition command, we get the new definition code window inline.

Sample Peek Definition code window

Don't you think this makes understanding the code a bit more intuitive?

Here's a little more on how to use Peek Definition in Visual Studio 2013.