VS2005:如何在当前函数中查找文本
在使用C#的VS2005代码编辑器中,如何仅在当前函数中搜索文本?它允许搜索当前文档,但我不知道如何将搜索限制为仅当前函数。
In the VS2005 code-editor using C#, how do you search for text in the current function only? It allows searching over the Current Document but I cannot see how to limit the search to only the current function.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
选择函数的代码,然后下拉列表中将出现一个新选项。该选项称为当前块。这将允许您仅在该特定功能内进行搜索。
来自 MSDN 上的来源: 快速查找、查找和替换窗口
Select the function's code and then a new option will be available in the dropdown list. This option is called Current Block. This will allow you to search only within that specific function.
From the source on MSDN: Quick Find, Find and Replace Window
大多数时候,您的函数应该足够短,这实际上不是问题,我的意思是。
有时,您可能几乎合理地需要某种具有许多不同标记的索引函数。即使在这种情况下,您也应该重构以使用数据库或反射或其他东西,因为这样您的代码就会出现在 DailyWtf.com 上。
但是,如果确实不可避免地需要这么长的函数,如果它是遗留代码,或者由于其他一些奇怪的原因,您可以采取一些措施:
Most of the time, your functions should be short enough that this really isn't an issue, and I mean that.
Occasionally, you might have an almost-legitimate need for some kind of indexing function that has a lot of distinct tokens. Even in this case, you should refactor to use a database or reflection or something, as this is the kind of thing that'll get your code featured on DailyWtf.com.
But if it's really unavoidable to have a function this long, if it's legacy code, or for some other weird reason, there are some things you can do: