Transferred from https://blogs.msdn.microsoft.com/scottgu/2011/10/08/visual-studio/
and http://www.cnblogs.com/rond/archive/2012/03/05/2380367.html
Thanks to the author ~
[Original post address] Search and navigation tips/tricks with Visual Studio
[Original published date] 2010/8/24 12:24 AM
[Transferred from]http://msdn.microsoft.com/zh-cn/gg232829
This is the 27th of the blog series I wrote about VS2010 and Net4.
Today's article continues my debugging tips last week and talks about the more useful search and browsing techniques in Visual Studio. My friend Scott Cate (who wrote a lot of blogs about vs usage tips and tricks) recently highlighted these good techniques to me, and most developers who use vs don't seem to know these techniques (even though most of them have been in the product development group for a while).
If you haven't used any of these techniques, hopefully this blog post will help you find them. They are easy to learn and can help you save a lot of time.
Ctrl + I progressive search
Most programmers who use Visual Studio are accustomed to pressing the CTRL + F key in the IDE to open the Find window. Surprisingly, there are many programmers who don't know about the "progressive search" feature in Visual Studio. It lets you search in the current document and allows you to search without opening the dialog box.
Using progressive Search
You can enable progressive search by pressing Ctrl + I in the editor. It will replace the mouse icon and change the bottom left corner of the IDE's status bar to "Incremental Search: (search keywords)"-you can type in keywords to search for, and the editor will start searching from where you are in the source code (without opening the dialog box).
Here we search for "action", vs will highlight the first time in the file where it is used.
We can then press Ctrl + I to search for the next place to use it (you can repeat it several times):
Press Ctrl + Shift + I to search in reverse direction, thus avoiding backtracking.
You can jump out of an incremental search by using the "ESC" key. Here are more detailed information about incremental search.
F3 and SHIFT + f3– use previous keywords to find
One cool tip about progressive search is that when you press ESC to exit the search, it adds keywords to the IDE's lookup stack. In the "Find" drop-down box on the Standard toolbar of VS, you can see the search keywords used:
In Visual Studio, pressing the F3 key allows you to repeat the last search. This is useful when you look up something, change the code, and then continue searching from where it was changed. As soon as you press F3, you can repeat the previous search (such as "action") in the new location of the document-no need to retype the search keyword.
Press Shift + F3 to reverse-search using the last search keyword (starting at the current position of the editor). You can easily search the document backwards and forwards with a combination of f3/shift+f3.
Ctrl + f3-Search for the currently selected text
Another search tip is that to avoid typing keywords, you can select a word (or part of a word) in the Code Editor and press Ctrl + F3 to find the next place to use it in the current file search:
Press Ctrl +F3 to search for the next instance of the selected text-this prevents you from typing it:
Similar to the previous one, you can use "Ctrl + Shift + F3" to reverse search, that is, to search backwards from the text.
Ctrl + Shift + F – Search in Solution
Sometimes you want to search through the solution.
The Find dialog box that is opened by Ctrl + F defaults to searching in the current document. The Find dialog box opened by Ctrl + Shift + F defaults to search throughout the solution:
Performing one of these searches opens the Find Results window in the IDE, where you can navigate to each instance of the Search keyword:
You can double-click an item in the Find Results window to jump to the point where the keyword appears.
One trick many people don't know is to press "F8" or "Shift + F8" to toggle between the items in the list. This makes it faster and easier to locate inside, so you don't have to use your mouse to move.
Shift + f12– Find purpose
Most programmers who use Visual Studio know that a type is selected, and then press F12 to "go to definition." It jumps to the definition type, which makes it easy to see the type definition.
But most programmers don't know about "Shift + F12"-it finds all the places that use a particular type. Lets you quickly find a type of usage. To use it, simply select or place the cursor in one type and press Shift + F12:
It then opens the Find Symbol Results window and lists all the places in the current solution that are used for this type:
As in front, press "F8" or "Shift + F8" to toggle between the items in the list.
CTRL + MINUS and SHIFT + CTRL + MINUS sign-forward/backward positioning
Open another code file, see something, and then want to go back to the location of the previous file, have you ever had this experience? For example, "go To Definition" with F12, and then jump back to the original code used for the type.
A function of VS, which many people don't know, is the "backtracking positioning" combination-"Ctrl + (minus key)". It jumps to the previous document or location in the navigation stack.
To see how it works, first select a type in Visual Studio. I have selected the "IController" interface below:
Press F12 to jump to its definition, open a new editor window and display the selected type of source code:
Now to get back to where we were, press Ctrl + minus key, and then vs will take us back to where we were:
And if you want to go forward in the navigation stack (that is, to return to the IController.cs file), press "Shift + Ctrl + (minus key)".
Sara Ford has a good article that delves into this feature and explains the conditions for pressing a new position into the navigation stack.
Ctrl + ALT + (down arrow) – Locate an open file
I've opened countless files in the IDE, and I want to find an easy way to walk through them.
A very useful key combination is "Ctrl + ALT + (down arrow)"-When vs displays a Drop-down box and lists all open files:
You can use the arrow keys to select the file you want to browse-or better start knocking on the filename, and Visual Studio will highlight it for you in the list. For example, I knocked on "Mo" above, and Visual studio highlighted "ModelBinder.cs". Pressing the "Enter" key will help me open that file:
This is a good, convenient way to browse between files without using a mouse, or to get your hands off the keyboard. Also remember that "Ctrl + (minus)" Allows you to return to your original position.
Navigate to, call hierarchy and reference highlighting
Visual Studio 2010 Provides a large number of new code positioning and lookup features-including the new Navigate to dialog box, the View Call Hierarchy feature, and the reference highlighting feature:
I mentioned the three new features of VS 2010 in my previous blog. If you have not read this article and experienced their energy, I highly recommend that you try-they are good additions.
15 Visual Studio 2010 usage tips to improve your development efficiency
Believe that do not pay attention to the development of efficiency. Development C#,VB know that we are very dependent on VS, or that we are thankful for vs. Being able to rely on an IDE means that the IDE does have its uniqueness. No doubt, VS is a very powerful IDE that supports multilingual editing. Support c#,vb,c/c++,html ... It has powerful debugging and compilation capabilities. It lets us not have to remember those installation, environment variable settings, server settings, compile the tedious process. Highly integrated. Everything has its pros and cons, in the era of agile development, vs whether it is worth our use is indisputable. But powerful vs also has numerous settings, many tricks. Remember that some tips can make it easier and quicker to use vs. This is very necessary. Everyone remembers some little tricks more or less. But it is not possible to remember all of us, we follow our own programming habits to remember some of our own more commonly used just fine.
Here are some of the tips I've found in the coding process and are more often used, and I hope it helps.
1. Line edit (copy, cut, delete, swap)
When you use the shortcut key ctrl+c,x,l in the cursor stop line, you can copy, cut, and delete the entire line. Of course, the right button is also OK. With the usual copy, cut, delete is checked and did not select the difference between the code.
If you want to swap two lines, you can use the shortcut key (shift+alt+t), provided the cursor stays on the line above. After the replacement, the cursor will always follow the original line.
2. Note (//todo: ...) )
If you look at the headline, you might want to hit me. The programmer does not know the annotation, not on//or/*.....*/or <!--....--> (html/xml annotation). But used
TODO: Annotation Section
, it's estimated to be a minority. If you like to use the "task List" to record something to do, this small feature is best for you. You can find the Task List window on the VS 2010 menu and click on the "menu-> View-> Task List" and you can also click on the shortcut "Ctrl+w,t". VS also provides, hack,untodu,unresolvedmergeconflict tag annotations, you can find and edit/Add/Remove tag annotations in the Tools-> options-> Environment-> task List. Here is the diagram:
3. Create the area (#region和 #endregion)
When the code is more and more, you expect to be able to hide some code, and #region and #endregion are such functions. You can hide any code in any location. Even hidden content does not belong to the same function. You can expand/hide the code by clicking #region next to + +. While hiding, when your cursor is placed on the note, vs will show the hidden code content. (I heard that vb.net use can only be written outside the method, can not be written in it.) Because I did not write VB, so may be in this regard will be misleading to everyone, thank you friends @ Born to remind of Li posture
4. Select a Word/select a string
As you know, when you double-click a word, you choose the whole word. You can also select a word by holding down the CTRL key and clicking anywhere in the word.
Double-click the left side of the first quotation mark for the string to select the entire string. You can also select the entire string by holding down the CTRL key before clicking the first quotation mark.