visual-studio 如何在 Visual Studio 中突出显示文本中出现的搜索词?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/256931/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 09:50:18  来源:igfitidea点击:

How to highlight occurrences of a search term in text in Visual Studio?

visual-studiosearchkeyboard-shortcutshighlighting

提问by axk

How do I make all occurrences of a phrase (search term) in a file to be highlighted in the VS code editor?

如何在 VS 代码编辑器中突出显示文件中所有出现的短语(搜索词)?

采纳答案by Andrew Theken

When you run a "find" you can click "bookmark all" which will identify on the left which lines the search terms occur on, but you can't "highlight" the elements using visual studio, out of the box.

当您运行“查找”时,您可以单击“全部书签”,这将在左侧标识搜索词出现在哪些行上,但您无法使用 Visual Studio 开箱即用地“突出显示”元素。

回答by Alex Duggleby

I noticed that a nice side effect of the Rock-Scroll plugin is that when you double-click a keyword it highlights all occurrences in the file (and in the rock scroll preview) as well.

我注意到 Rock-Scroll 插件的一个很好的副作用是,当您双击一个关键字时,它也会突出显示文件中(以及岩石滚动预览)中的所有出现。

http://microsoftdev.blogspot.com/2008/05/rock-scroll-visual-studio-plugin.html

http://microsoftdev.blogspot.com/2008/05/rock-scroll-visual-studio-plugin.html

Hope that helps, Alex

希望有帮助,亚历克斯

回答by remotefacade

ReSharper can do this with the Highlight Usages feature: Highlight Usages In File

ReSharper 可以通过突出显示用法功能来做到这一点:突出显示文件中的用法

Course, you need ReSharper ;)

当然,你需要 ReSharper ;)

回答by USER_NAME

You can use metalScroll extension - it is like rockscroll but it has rich and very useful functions. You can download this on:

您可以使用 metalScroll 扩展 - 它就像 Rockscroll 但它具有丰富且非常有用的功能。您可以在以下位置下载:

http://code.google.com/p/metalscroll/downloads/list

http://code.google.com/p/metalscroll/downloads/list

go through with this before use:

使用前请完成此操作:

http://code.google.com/p/metalscroll/

http://code.google.com/p/metalscroll/

回答by Eoin Campbell

If you use the CTRL-i short cut, it'll do an inline incremental search. Keep pressing CTRL-i to jump to & highlight each subsequent occurence in the file.

如果您使用 CTRL-i 快捷方式,它将执行内联增量搜索。继续按 CTRL-i 跳转到并突出显示文件中的每个后续出现。

I'm not sure that you can highlight all occurences at once. It may be possible with a plugin like ReSharper but not that I'm aware of.

我不确定您是否可以一次突出显示所有事件。使用像 ReSharper 这样的插件可能是可能的,但我不知道。

回答by Christopher

Microsoft has an (actually) useful VS plugin which solves this issue.

Microsoft 有一个(实际上)有用的 VS 插件可以解决这个问题。

Power Tools: http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef/

电动工具:http: //visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef/

Once installed (restart VS afterwards), either highlight a section of text an hit CTRL+F to iterate all occurrences, or highlight text and let VS mark all matches for you in syntax highlighting.

安装后(之后重新启动 VS),要么突出显示一段文本,然后按 CTRL+F 以迭代所有出现的内容,要么突出显示文本并让 VS 在语法突出显示中为您标记所有匹配项。

回答by Doctor Rudolf

CTRL + F3

CTRL + F3

  • sends current word to find, regardless if it is selected or not
  • steps to the next occurrence
  • AND highlights all occurrences in editor
  • 发送要查找的当前单词,无论它是否被选中
  • 下一次出现的步骤
  • 并突出显示编辑器中的所有事件

TIP: Use SHIFT+CTRL+F3 to "step backwards"

提示:使用 SHIFT+CTRL+F3 来“后退”

回答by JohnnyBizzle

I copied and pasted the source code into Word 2007. This has highlight all option called 'Reading Highlight'. This keeps the highlighting on even when you search for another term.

我将源代码复制并粘贴到 Word 2007 中。这突出显示了所有名为“阅读突出显示”的选项。即使您搜索另一个术语,这也会保持突出显示。

回答by NitroxDM

I open the file in Notepad++ and VS.

我在 Notepad++ 和 VS 中打开文件。

Update:

更新:

I recently found this extentnion for VS that makes it behave like notepadd++! You just need to select a phrase and it will highlight all of them.

我最近发现 VS 的这个扩展使它的行为像记事本 ++!您只需要选择一个短语,它就会突出显示所有短语。

Highlight all occurrences of selected word

突出显示所选单词的所有出现