Home Database Mysql Tutorial Visual Studio里面的搜索和浏览的一些技巧

Visual Studio里面的搜索和浏览的一些技巧

Jun 07, 2016 pm 03:41 PM
studio visual Skill search yes Browse

这是我写的关于VS2010和.Net4的 博客系列 的第27篇。 今天的文章继续上星期我的 调试技巧文章 ,并谈谈Visual Studio里比较有用的搜索和浏览的技巧。我的朋友 Scott Cate (他写了很多关于VS使用技巧和窍门的 博客 )最近向我强调了这些很好的技巧,大部分使

这是我写的关于VS2010和.Net4的博客系列的第27篇。

今天的文章继续上星期我的调试技巧文章,并谈谈Visual Studio里比较有用的搜索和浏览的技巧。我的朋友Scott Cate(他写了很多关于VS使用技巧和窍门的博客)最近向我强调了这些很好的技巧,大部分使用VS的开发人员好像不知道这些技巧(即使他们大部分都在产品开发组呆过一阵子)。

如果你还没有使用过这些技巧,希望这篇博文能帮你发现它们。 它们学起来很容易,能帮你节省很多时间。

Ctrl + i渐进搜索

大多数使用Visual Studio的程序员都习惯了在IDE里按“Ctrl + F”键来打开“查找窗口”。但令人惊讶的是,有很多程序员不知道Visual Studio里的“渐进搜索”这个功能。它可以让你在当前文档里进行搜索,而且允许你不用打开对话框就可以搜索。

使用渐进搜索

在编辑器里按“Ctrl + i”即可启用渐进搜索。它会换掉鼠标图标,并将IDE状态栏的左下角改成“渐进式搜索:(搜索关键字)”—你可以键入要搜索的关键字,并且编辑器会从你在源代码的位置开始搜索(不用打开对话框)。

下面我们搜索“action”,VS会在文件里高亮第一次使用到它的地方。

Visual Studio里面的搜索和浏览的一些技巧

我们可以接着按“Ctrl + i”来搜索下一个用到它的地方(可以重复多次):

Visual Studio里面的搜索和浏览的一些技巧

按“Ctrl + Shift + i”可以反方向搜索,这样避免回溯。

你可以通过“Esc”键跳出渐进式搜索。这里有关于渐进式搜索更详尽的资料。

F3和Shift + F3 –使用以前的关键字查找

关于渐进式搜索的一个很炫的技巧是,当你按下ESC键退出搜索时,它会将关键字添加到IDE的查找栈里。在VS的标准工具栏上的“查找”下拉框,你可以看到用过的搜索关键字:

Visual Studio里面的搜索和浏览的一些技巧

在Visual Studio里,按F3键可以让你重复上次的搜索。这在你查找一些东西,改一下代码,然后要从改动过的地方继续搜索的时候非常有用。只要按下F3,你就可以在文档新的位置上重复上次的搜索(例如“action”)—不需要重新键入搜索关键字。

按“Shift + F3”可以使用 上次搜索关键字进行反向搜索(从光标在编???器的当期位置开始)。你可以很方便地用F3/Shift+F3的组合在文档里向前向后搜索。

Ctrl + F3—搜索当前选择的文本

另外一个搜索技巧是,为了避免键入关键字,你可以在代码编辑器里选中一个单词(或单词的一部分),然后按“Ctrl + F3”来在当前文件搜索下一个用到它的地方:

Visual Studio里面的搜索和浏览的一些技巧

按“Ctrl +F3”搜索选中文本的下一个实例—这样避免你键入它:

Visual Studio里面的搜索和浏览的一些技巧

跟前面讲的类似,你可以用“Ctrl + Shift + F3”来进行反向搜索,即从文本里回溯搜索。

Ctrl + Shift + F –在解决方案里搜索

有时你会想在整个解决方案里进行搜索。

“Ctrl + F”打开的查找对话框默认是在当前文档进行搜索。“Ctrl + Shift + F”打开的查找对话框默认在整个解决方案里进行搜索:

Visual Studio里面的搜索和浏览的一些技巧

执行一个这样的搜索,会打开IDE里的“查找结果”窗口,你可以在里面定位到搜索关键字的每个实例:

Visual Studio里面的搜索和浏览的一些技巧

你可以在“查找结果”窗口里双击一项来跳到关键字出现的地方。

有一个很多人都不知道的技巧,就是按“F8”或者“Shift + F8”可以在列表的前后项之间切换。这使得在里面定位变得更快更容易,这样就不用使用鼠标来进行移动了。

Shift + F12 –查找用途

大部分使用Visual Studio的程序员都知道选中一个类型,然后按F12来“转到定义”。它会跳转到定义类型的地方,这样查看类型定义就变得很方便。

但大部分程序员都不知道“Shift + F12”—它会找出所有用到一个特定类型的地方。让你快速找到一个类型的用法。要用它,只要选中或者把光标放在一个类型,然后按“Shift + F12”:

Visual Studio里面的搜索和浏览的一些技巧

然后它会打开“查找符号结果”窗口,并列出当前解决方案里所有用到这个类型的地方:

Visual Studio里面的搜索和浏览的一些技巧

跟前面一样,按“F8”或者“Shift + F8”可以在列表的前后项之间切换。

Ctrl +减号和Shift + Ctrl +减号–向前/向后定位

打开另一个代码文件,查看一些东西,然后想回到前面文件的位置,这样的经历你有过吗?比如说,用F12“转到定义” 后,然后要跳回原来用到类型的代码那里?

一个很多人都不知道的VS的功能,就是“回溯定位”组合键—“Ctrl + (减号键)”。它会在导航栈中跳转到以前的文档或者位置。

要看它是如何工作的,请先在Visual Studio里选中一个类型。下面我选中了“IController”接口:

Visual Studio里面的搜索和浏览的一些技巧

按F12跳到它的定义处,会打开一个新的编辑器窗口并显示选中类型的源代码:

Visual Studio里面的搜索和浏览的一些技巧

现在要回到我们当初的位置,按“Ctrl + (减号键)”,然后VS就会把我们带回原来的地方:

Visual Studio里面的搜索和浏览的一些技巧

而如果你想要在导航栈里往前走(也就是要回到IController.cs文件),那就按“Shift + Ctrl + (减号键)”。

Sara Ford有一篇不错的文章深入讲解了这个功能,还解释了将新的位置压入导航栈的条件。

Ctrl + Alt +(向下键)-定位一个打开的文件

曾经在IDE里打开了数不清的文件,想要找到一个容易的方法漫步其中?

一个很有用的按键组合就是“Ctrl + Alt + (向下键)”—这时VS会显示一个下拉框并列出所有打开的文件:

Visual Studio里面的搜索和浏览的一些技巧

你可以使用箭头键来选择要浏览的文件—或者最好开始敲文件名,Visual Studio会为你在列表里高亮它。比如说,上面我敲了“Mo”,Visual Studio高亮“ModelBinder.cs”。按下“Enter”键就会帮我打开那个文件:

Visual Studio里面的搜索和浏览的一些技巧

这是一个在文件之间很好的、便利的浏览方式,不需要使用鼠标,或者要让你的手离开键盘。另外记住“Ctrl + (减号)”可以让你回到原来的位置。

定位到,调用层次结构和引用高亮功能

Visual Studio 2010提供了一大批新的代码定位和查找功能—包括新的“定位到”对话框,“查看调用层次结构”功能和引用高亮功能:

Visual Studio里面的搜索和浏览的一些技巧

我在之前的博客里提到了VS 2010这三个新功能。如果你还没有读过这篇文章并体验它们的能量,我非常推荐你去试试—它们是很好的补充。

编辑器其他方面的改进

VS 2010里面有数不清的改进—我在之前的博客里也提到很多。这使我之前的几篇VS 2010编辑器的文章:

·改进过的C#/VB代码智能感知

·改进过的JavaScript代码智能感知

·框选和多行编辑支持

·ASP.NET, HTML和JavaScript代码片段支持

另外也请看看我关于VS 2010和.NET 4改进系列的其他博客。

总结

上面大部分功能实际在Visual Studio已经存在了好几个版本—但还是有非常多的程序员不知道他们。希望这篇博客提供了一条捷径帮你了解它们。如果你需要记住这些按键—打印一份VS 2010快键招贴画,并贴在你显示器旁边。

如果还要学习更多的Visual Studio技巧,请订阅Scott Cate的Visual Studio技巧系列文章(里面已经有83个超棒的技巧了),也可以订阅Sara Ford的博客—历年来,她也有一个很棒的技巧集。

希望这能对您有所帮助。

Scott


原文:http://weblogs.asp.net/scottgu/archive/2010/08/24/search-and-navigation-tips-tricks-with-visual-studio.aspx

中文翻译:http://blogs.msdn.com/b/scottgu/archive/2011/10/08/visual-studio-1.aspx


Visual Studio里面的搜索和浏览的一些技巧

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Win11 Tips Sharing: Skip Microsoft Account Login with One Trick Win11 Tips Sharing: Skip Microsoft Account Login with One Trick Mar 27, 2024 pm 02:57 PM

Win11 Tips Sharing: One trick to skip Microsoft account login Windows 11 is the latest operating system launched by Microsoft, with a new design style and many practical functions. However, for some users, having to log in to their Microsoft account every time they boot up the system can be a bit annoying. If you are one of them, you might as well try the following tips, which will allow you to skip logging in with a Microsoft account and enter the desktop interface directly. First, we need to create a local account in the system to log in instead of a Microsoft account. The advantage of doing this is

WPS table cannot find the data you are searching for, please check the search option location WPS table cannot find the data you are searching for, please check the search option location Mar 19, 2024 pm 10:13 PM

In the era dominated by intelligence, office software has also become popular, and Wps forms are adopted by the majority of office workers due to their flexibility. At work, we are required not only to learn simple form making and text entry, but also to master more operational skills in order to complete the tasks in actual work. Reports with data and using forms are more convenient, clear and accurate. The lesson we bring to you today is: The WPS table cannot find the data you are searching for. Why please check the search option location? 1. First select the Excel table and double-click to open it. Then in this interface, select all cells. 2. Then in this interface, click the "Edit" option in "File" in the top toolbar. 3. Secondly, in this interface, click "

How to search for stores on mobile Taobao How to search for store names How to search for stores on mobile Taobao How to search for store names Mar 13, 2024 am 11:00 AM

The mobile Taobao app software provides a lot of good products. You can buy them anytime and anywhere, and everything is genuine. The price tag of each product is clear. There are no complicated operations at all, making you enjoy more convenient shopping. . You can search and purchase freely as you like. The product sections of different categories are all open. Add your personal delivery address and contact number to facilitate the courier company to contact you, and check the latest logistics trends in real time. Then some new users are using it for the first time. If you don’t know how to search for products, of course you only need to enter keywords in the search bar to find all the product results. You can’t stop shopping freely. Now the editor will provide detailed online methods for mobile Taobao users to search for store names. 1. First open the Taobao app on your mobile phone,

A must-have for veterans: Tips and precautions for * and & in C language A must-have for veterans: Tips and precautions for * and & in C language Apr 04, 2024 am 08:21 AM

In C language, it represents a pointer, which stores the address of other variables; & represents the address operator, which returns the memory address of a variable. Tips for using pointers include defining pointers, dereferencing pointers, and ensuring that pointers point to valid addresses; tips for using address operators & include obtaining variable addresses, and returning the address of the first element of the array when obtaining the address of an array element. A practical example demonstrating the use of pointer and address operators to reverse a string.

What are the tips for novices to create forms? What are the tips for novices to create forms? Mar 21, 2024 am 09:11 AM

We often create and edit tables in excel, but as a novice who has just come into contact with the software, how to use excel to create tables is not as easy as it is for us. Below, we will conduct some drills on some steps of table creation that novices, that is, beginners, need to master. We hope it will be helpful to those in need. A sample form for beginners is shown below: Let’s see how to complete it! 1. There are two methods to create a new excel document. You can right-click the mouse on a blank location on the [Desktop] - [New] - [xls] file. You can also [Start]-[All Programs]-[Microsoft Office]-[Microsoft Excel 20**] 2. Double-click our new ex

VSCode Getting Started Guide: A must-read for beginners to quickly master usage skills! VSCode Getting Started Guide: A must-read for beginners to quickly master usage skills! Mar 26, 2024 am 08:21 AM

VSCode (Visual Studio Code) is an open source code editor developed by Microsoft. It has powerful functions and rich plug-in support, making it one of the preferred tools for developers. This article will provide an introductory guide for beginners to help them quickly master the skills of using VSCode. In this article, we will introduce how to install VSCode, basic editing operations, shortcut keys, plug-in installation, etc., and provide readers with specific code examples. 1. Install VSCode first, we need

What is the Excel search shortcut key? What is the Excel search shortcut key? Mar 20, 2024 am 10:52 AM

Want to know what the Excel search shortcut key is? The answer is simple, just use [Ctrl+F] to perform a quick search. We often use Excel to record a lot of different data and names. If we need to change it, it will be inconvenient for us to search because there is too much data, and it will be quite troublesome to search. In fact, we can use a quick search shortcut to find the data we need to change! So, what is the search shortcut key in Excel? Today I’m going to teach you how to use the shortcut search keys in excel tables to save you time and effort in your work. Here I am using this version of Microsoft Office excel 2010 for demonstration. Students who need it can

How to search other people's resources on Alibaba Cloud Disk How to search other people's resources on Alibaba Cloud Disk Mar 30, 2024 am 10:31 AM

Alibaba Cloud Disk, this popular storage tool, not only helps us manage personal resources efficiently, but also provides many convenient functions. So many users may not be able to find cloud disk resources when searching, so they want to search all resources in the entire disk. So below, the editor of this site will answer this question in detail and share the specific search method. Users who want to know, please come and follow this article to learn more! How to search other people's resources in Alibaba Cloud Disk 1. First, search the specific path of the resource file in the folder directory of Alibaba Cloud Disk to find the corresponding folder. 2. Then use the file search function and enter the keywords you want to find to find the relevant file content. 3. Then we share the link with others to directly locate and download

See all articles