Visual Studio 2013 Preview: Peek Definition aka Go To Definition (Peek)

Traditionally when you want to view the definition of a method you place your cursor inside the call:

5-16-2012 12-26-10 PM

 

Then press F12 to go to the document where the definition exists:

5-16-2012 12-27-17 PM

 

 

Using Peek

But what if you don’t want to leave your current location:

5-16-2012 12-26-10 PM

 

No problem! Just take advantage of the new Peek Definition feature by pressing ALT+F12:

5-16-2012 12-29-03 PM

 

This feature will actually open a small window below the method call so you can view its definition. This makes it very easy to view a definition without losing your place in the current document.

 

 

If I want to go to another definition from here I can just place my cursor inside the item:

5-16-2012 2-25-33 PM

 

And press ALT+F12 again. It will update the window to show the new definition:

5-16-2012 2-27-51 PM

 

But something else also happens. Notice the dots showing up in the top right-hand side of the window:

5-16-2012 2-29-46 PM

 

The Peek window is keeping track of the definitions you have been to so you can navigate easily between them:

5-16-2012 2-31-06 PM

 

You can use your mouse to click any of the dots or the forward and back links. Also, as you can see, you can use CTRL+ALT+Minus(-) and CTRL+ALT+Plus(+) to move backward and forward respectively.

 

I’m not sure what the upper limit is on number of entries it will remember but at 18 entries the More indicators showed up to allow navigating through a higher number of definitions. I suspect the number of entries can go quite high:

5-16-2012 2-42-08 PM

 

Finally

The next most obvious question is: “Can I edit the code in this definition window?” Currently the answer is “no” however it is something that is being considered before we ship. Let me know your thoughts.