Here is a list of the top 11 Visual Studio features that I use just about every day (yes, including the weekend). If you’re new to using Visual Studio, I recommend giving these a go and then get into the rhythm of using them often. If you’ve been coding in Visual Studio for years, this list may serve as a refresher, or you may even learn something new.
1. Open IntelliSense popup
Let’s start off with a simple one – opening the IntelliSense popup. IntelliSense is Visual Studio’s way of auto-completing names based on what you type and what’s available in the current context. If you’re calling a method, for example, you’ll see a popup containing only method names accessible on the class you’re calling on. (And any available extension methods), filtered by what you’ve typed so far. The popup allows you to hit the Return key generally after typing a few characters to complete the method name and swiftly start typing the parameters. The IntelliSense popup automatically opens as you type, but sometimes you may lose it – say if you are navigating away and back. Or sometimes you may want to open it without having typed anything yet. Use the Ctrl+Space keyboard shortcut to manage this.
Naming can be hard to get right the first time. Sometimes naming something is always hard. Renaming, on the other hand, is super easy in Visual Studio. By replacing the name of a class, interface, method, namespace, property, variable, constant, delegate, event and so on, the name will be surrounded by a dotted line. While the caret is still within the name, you can press Ctrl+. and Visual Studio will ask if you want to rename that member. Hit Return to apply the rename which will update all the references to that member too – saving a lot of otherwise manual work. You will lose the option to rename if you make any other changes to the file while the dotted line surrounds the name.
Renaming a file in the solution explorer will often cause Visual Studio to ask you if you want to perform a rename in the class within that file. Make sure to rename files first if you intend to rename the class to save a bit of time.
3. Conditional breakpoints
A breakpoint is a flag that you can set on a line of code that will cause the Visual Studio debugger to pause code execution when the running process reaches that line of code. You can also view the application state to check that everything is fine or to debug why something is not working as expected. A breakpoint can be added by either clicking the gray margin to the left of the line of code or by pressing F9 while the caret is on the line of code. If a line of code is hit many times, such as within a loop, while you’re trying to debug, getting to the breakpoint while the application is in the state that you want to investigate can be a time sink.
Conditional breakpoints help save time here. Right-click a breakpoint and select “Condition” or use the Alt+F9 keyboard shortcut. With the popup, you can check for all sorts of conditions such as if a particular value equals an expected value, or if it has hit a breakpoint. The text box for entering a condition even has IntelliSense to help avoid coding typos. Instead of manually stepping through a breakpoint many times this is a great way to avoid coding errors.
4. Find allCtrl+F is great but only gives you the option to step through each search result one at a time. Once you lose focus from the search dialog, you need to loop through all the search results again, rather than continuing from where you were. Find all is where it’s at, which you can initiate using the Ctrl+Shift+F keyboard shortcut. The Ctrl+Shift+F shortcut will open a different dialog with more search options, the main one I use of which is to specify what types of files to search through. By clicking Find All, you’ll get a list of all search results ordered by file, allowing you to scan through them however you like. Once you’ve found the right result, click on it to navigate to the code. The search list persists in the find results window allowing you to examine other results whenever you need to.
5. Go To Definition
As a project grows, navigating around code within many many files can start to become time-consuming. Fortunately, Visual Studio has many simple features to speed up and simplify code navigation. “Go To Definition” is one of the navigation features that I use the most. Within your code, click on any usage of a member, such as a class or a method, then hit F12 to navigate the definition of that member. The F12 shortcut is used to revise the implementation of a method or to jump to a class where you plan to add a new member.
6. Go To Implementation
A lot of my code implements interfaces, and those implementations use interfaces to call other code. Hitting F12 on a method that’s only known by its interface will land you in the interface definition, which sometimes isn’t what you want. To get to an implementation of that interface, use Ctrl+F12 instead. If Visual Studio only knows of one implementation to that interface, it will take you there straight away. If there are multiple implementations, Visual Studio will present you with a list.
7. View all references
In more recent versions of Visual Studio, displaying the definition of a class or method will show the number of references to that class or method just above the name. Clicking this number will open a popup displaying a list grouped by file name. Alternatively, or in older Visual Studio versions, click on the class or method name, and then either use the Ctrl+K, R shortcut or right-click and select “Find All References.” Visual Studio 2017 will be bringing further improvements to the find all references feature which you can read about here.
NavigateTo allows you search for something without knowing or remembering where it is (or any of its references). Scott Hanselman also names this as one of his favorite features of Visual Studio, and it’s one I use all the time, too.
“Absolutely high on the list of useful things is Ctrl+, for NavigateTo. Why click around with your mouse to open a file or find a specific member or function?”
To get a filtered list of options quickly, use the shortcut Ctrl+, :
9. Navigate backward and forward
As you navigate around your code, be it via the solution explorer, or using any of the navigation features described above, Visual Studio remembers the path you’ve taken, much like navigating the Internet in a browser. Navigate backward and forward along this path quickly using the keyboard shortcuts Ctrl+- to go backward and Ctrl+Shift+- to go forward. Visual Studio displays the “Standard” toolbar by default. The backward button has a drop down allowing you to jump to a particular point, rather than one at a time. If you’ve got a mouse that has backward and forward buttons, then you can use those in place of the keyboard shortcuts which is much faster.
10. Sync with active document
Once you’ve found a class, you may want to find or add a class to the same folder that it lives within. If you have no idea where the class lives in the solution explorer, just get Visual Studio to guide you. Use the keyboard shortcut Ctrl+[, S or hit the double arrows icon in the solution explorer toolbar. The toolbar will expand, scroll to and highlight the file you’re currently editing:
11. (Bonus feature) Customize keyboard shortcuts
One of the most useful Visual Studio features is the ability to customize your keyboard shortcuts. In the menu, click “Tools” and then “Options…”. Head to the sidebar, expand “Environment” and then select “Keyboard.” Use the search box to type part of the name of the feature you’re editing with no spaces, such as activedocument for the above feature. Focus on the “Press shortcut keys” box and input the keyboard shortcut you want. The box below will display the feature(s) that are also using that keyboard shortcut so that you can avoid any unwanted conflicts. Hit OK and try it out.
It’s all about saving time
Most of these features, for me, are all about saving time. Which Visual Studio features do you use all the time that help save time and supercharge your coding skills? Comment below!