Visual Studio Peek Definitions

I just recently discovered the new Peek Definitions feature in Visual Studio 2013, and thought I’d share a short post about it. There is a pretty comprehensive description of it here, so this is just a short summary and example of the basics. You’ll find a list of the most important keyboard shortcuts at the end of this article.

Peeking at the implementation of a method.


What I’ve done here is clicked DoSomethingElse() so the caret is positioned there, then pressed Alt + F12 to open it’s implementation in a “Peek” window. Previously I’ve relied on the F12 (“Go To Definition”), or the Resharper shortcut Alt + End (“Go to inheritors”) whenever I wanted a quick glance at the implementation of a method. Ctrl + – would let me return quickly to the original code location. That however, would take me away from where I was working, even if only for a few of seconds. Sometimes we may need to navigate more than one step, i.e. into another method call buried somewhere within the first. A few more steps, and things can quickly get confusing. Using the Peek Definition option lets you see not only the first, but several next steps in the same little window, right next to the code you are working on, making it easier to keep focus. Take this next example, and note the dots at the top (marked with a red circle):


Peeking at the implementation of a method several calls down (the third level, as marked by the blue dot).

Here, I’ve navigated into DoSomethingElse(), and taken two more steps “downwards” into the implementation, still without loosing sight of my current position. The three dots tells me that I have three levels in my Peek window, and the marked blue dot shows that I am currently showing the third level. I can easily navigate back upwards by clicking another dot,  make the Peek window into a proper code-window by clicking the little tab-icon, or just close the window when I’m done. It’s a simple and effective way to explore code without loosing the big picture.


NOTE: There is currently an error in the linked description; the shortcut to promote a Peek window to a full document window is (at least in my VS setup) not Shift + Alt + Home as stated there, but rather Ctrl + Alt + Home.

  • Peek: Alt + F12

  • Navigate forward and back in peek history (dots): Ctrl + Alt + + and Ctrl + Alt + –

  • Change peek window into a full window:  Ctrl + Alt + Home 

  • Close the Peek window: Esc