Peek Feature in Visual Studio

Let's have a look into the Peek Definition feature in Visual Studio.

What is Peek Definition

“Peek” means a quick look and in this context it refers to a class or method “Definition” that you are working on.

Why we required

Just simply, it can increase a developer's productivity and decrease the time spent working on specific code by providing a view of the definition without moving from the current location or losing sight of the code.

Here is an example. Place the cursor on or select a method or class, then right-click “Peek Definition” or Alt+F12 from the keyboard. A small window will open below the class with the definition information.

information

Now check this, the “Promote to Document” icon (marked with the red box); click on it and it will take you to the “Go To Definition” feature. So “Peek Definition” is just an extender or a quick look of the “Go To Definition” feature. So I hope you understand the difference between the “Peek Definition” and “Go To Definition” feature.

Ok, let’s dig in some more. Here is an example.

cs code

Let’s peek into the Vehicle class. The definition window is opened.

veicle

Now let’s peek into IVehicle… the interface definition has been opened, like in the following we can look into more definitions.

iveicle

Check the green box highlighted where we can see two dots that acts as peek history. The peek window that will keep the definition track and we can easily navigate between them. Keyboard navigation is also available with CTRL + ALT + Minus sign and CTRL + ALT + Plus sign.


Similar Articles