The GoTo tool window is a combination of the old GoTo Line and NavigateTo tools. Learn more how this new tool window searches the solution for files, types, members, and line numbers and supports filters to quickly limit the result list.
- [Voiceover] I don't know about you but when I'm working on a project especially a medium or large sized project I sometimes need help finding the file or the type or the class that I'm looking for. I'm grateful that Visual Studio has a number of tools to make my life easier. And I'll show you what I'm talking about. You can go to the project press F5, you'll get this dialogue. The find and replace dialogue. Or if you're in a file and you do control F you get a little tool window that let's you look inside this document.
So, if I look for the word title. You can see it's highlighted inside the file. It's currently scoped for the current document but I can expand the scope by using this drop down. Also the solution explorer has this search box at the top. So if I type in a string like this and press enter, it's filtering down my view of the solution explorer to just the items that have that text. Now these features have been around for several versions of Visual Studio. What I want to talk about today in this video is a go to feature.
Now this is a combination of an old feature which was called go to line, and it's a renaming of an old feature called navigate to. And I want it the way Microsoft also edited the UI to make it more useful. So let me show you what I'm talking about. I'll unfilter the solution explorer. Open up the program .cs file, and then I'll go to the edit menu and look at this first item and you'll see there are a number of go to items here.
Go to line's first, then we got go to wall and then four more, file, type, member and symbol. So go to line is similar to the old go to where you're inside a file. You type in the line number that you want to go to, and so 10. And you'll see after about a second or two in Visual Studio a highlight appears on line 10. Now I'll go to line 20. Wait a second or so and you'll see the highlight moves down there.
If I close this tool window by pressing enter the tool window disappears and you can see my cursor sitting there on line 20. I can bring up that window again if the focus is in the code window by doing a control g. If I try to type a number that's too large I get this message that says "Please enter a line between 1 and 26.". So I get some help telling me that there's not as many lines as I thought there were. This is really useful on a large file. Now, let's talk about all the other go tos.
The visual studio team has modified this so that you can not only go to a line but you can go to these other items and there's several ways of filtering this. When you have the go to up and there's no text in it like I've erased everything in the text right now, it's go to all. I can just filter this to look for files by clicking on this button. And you'll see that Visual Studio puts this f in there. Erase the f, and I'll type in f space, that also turns on the file button.
Or I can close this tool window go back to edit, go back to edit and choose go to file and it opens up the go to puts the f in there highlights the file button and in this case it also picked up whatever I had underneath my cursor. So if I had selected UpdatePrice, that's what shows up in the tool window. I'm seeing no results.
So, what I'm trying to point out here is there's essentially three ways of opening the go to and then selecting the filter. Click on the button, use the prefix or use this menu if you don't know what the prefixes are, don't worry. See where it says "Type ? To get help" ? Let's do that. So this shows you what the prefix is # for symbols, : for line f for files and so on. So now that we know how to filter this let's actually look for something so let's look for Author.
Because I don't have a prefix or I haven't selected one of these buttons it's doing a go to all and it's finding everything in the project that matches it. So it's finding is class and again if I select the item here in this go to it will move me there. There's a class called Author. There is a property inside the book class of type Author. There's a class called AuthorDataSource. There's a cs file called Author.
There is a add author method. And of course if I only want to see a portion of this I can come over and say just show me the files that have the word author in it. Show me the types that have the word author in it. Show me the symbols, the symbols is a combination of members and types. And here's the members. Let's try another search. Let's look for the word book. Try that again.
Book. You can see I get a lot more sources here including this Booklist.txt file shows up in my search results. So what the idea is is that you can use this to search through your entire project for what you're looking for and then go to it. The go to part means that when I select it it moves me to that item.
- Installing Visual Studio 2017
- Using debugging features
- Reviewing document navigation enhancements
- Examining IntelliSense Improvements
- Using XAML tools
- Reviewing the tooling added to support Docker containers
- Debugging without the hosting process
- Using the Visual Studio 2017 Installer