visual-studio Visual Studio 相同标记突出显示

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32494/
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-09-13 16:24:35  来源:igfitidea点击:

Visual Studio identical token highlighting

visual-studiovisual-studio-2008visual-studio-2005

提问by Darren Steinweg

I coded a Mancala game in Java for a college class this past spring, and I used the EclipseIDE to write it. One of the great (and fairly simple) visual aids in Eclipse is if you select a particular token, say a declared variable, then the IDE will automatically highlight all other references to that token on your screen. Notepad++, my preferred Notepad replacement, also does this.

今年春天,我用 Java 为大学课程编写了一个 Mancala 游戏,并使用EclipseIDE 编写了它。Eclipse 中一个很棒的(而且相当简单的)视觉辅助是如果您选择一个特定的标记,比如一个声明的变量,那么 IDE 将自动在您的屏幕上突出显示对该标记的所有其他引用。 Notepad++,我首选的记事本替代品,也这样做。

Another neat and similar feature in Eclipse was the vertical "error bar" to the right of your code (not sure what to call it). It display little red boxes for all of the syntax errors in your document, yellow boxes for warnings like "variable declared but not used", and if you select a word, boxes appear in the bar for each occurrence of the word in the document.

Eclipse 中另一个简洁且类似的功能是代码右侧的垂直“错误栏”(不知道该叫什么)。它为文档中的所有语法错误显示小红框,为“声明变量但未使用”之类的警告显示黄色框,如果您选择一个词,则该词在文档中每次出现时都会出现在栏中。

A screenshot of these features in action: screenshot

这些功能的屏幕截图: 截屏

After a half hour of searching, I've determined that Visual Studio cannot do this on its own, so my question is: does anyone know of any add-ins for 2005 or 2008 that can provide either one of the aforementioned features?

经过半个小时的搜索,我确定 Visual Studio 无法自行执行此操作,所以我的问题是:有没有人知道 2005 或 2008 的任何加载项可以提供上述功能之一?

Being able to highlight the current line your cursor is on would be nice too. I believe the add-in ReSharper can do this, but I'd prefer to use a free add-in rather than purchase one.

能够突出显示光标所在的当前行也很好。我相信插件 ReSharper 可以做到这一点,但我更愿意使用免费插件而不是购买插件。

采纳答案by Darren Steinweg

In a different question on SO (link), someone mentioned the VS 2005 / VS 2008 add-in "RockScroll". It seems to provide the "error bar" feature I was inquiring about in my question above.

在关于 SO(链接)的另一个问题中,有人提到了 VS 2005 / VS 2008 插件“RockScroll”。它似乎提供了我在上面的问题中询问的“错误栏”功能。

RockScroll

摇滚卷轴

EDIT: RockScroll also does the identical token highlighting that I was looking for! Great!

编辑:RockScroll 也做了我正在寻找的相同标记突出显示!伟大的!

回答by Alex_P

There is a RockScroll alternative called MetalScrollwhich is essentially the same thing with a few tweaks and improvements.

有一个叫做MetalScroll的 RockScroll 替代,它本质上是一样的,只是做了一些调整和改进。

Also there is a small and simple WordLightplug-in that only highlights the identical tokens.

还有一个小而简单的WordLight插件,它只突出显示相同的标记。

Both are open source and support code folding which is nice.

两者都是开源的,并且支持代码折叠,这很好。

Imho, the bar next to the scroll bar in Eclipse is a lot more elegant solution than the scroll bar replacement of RockScroll/MetalScroll. Unfortunately I couldn't find any VS plug-ins that do it the Eclipse way, so I just stick with WordLight.

恕我直言,Eclipse 中滚动条旁边的栏是比 RockScroll/MetalScroll 的滚动条替换更优雅的解决方案。不幸的是,我找不到任何以 Eclipse 方式执行此操作的 VS 插件,因此我只使用 WordLight。

回答by meetjaydeep

Check following addins Productivity Power Tools- Displays error in scrollbar and

检查以下插件 生产力电动工具- 在滚动条中显示错误和

Highlight selected word

突出显示选定的单词

回答by Roman Starkov

Old question but... Visual Studio 2010 has this feature built-in, at last.

老问题但是...... Visual Studio 2010 终于内置了这个功能。

回答by Codeguard

The highlight functionality is conveniently implemented in VisualAssist. In my opinion, they are both must-have.

VisualAssist 中可以方便地实现突出显示功能。在我看来,它们都是必备的。

1) Highlight identifier under editing caret: Options -> Advanced -> Refactoring -> Automatically highlight references to symbol under cursor

1) 在编辑插入符号下突出显示标识符:选项 -> 高级 -> 重构 -> 自动突出显示对光标下符号的引用

2) Highlight search result - in all windows. Works for RegExps! Options -> Advanced -> Display -> Highlight find results

2) 突出显示搜索结果 - 在所有窗口中。适用于正则表达式!选项 -> 高级 -> 显示 -> 突出显示查找结果

回答by Steve Gury

The automatic highlight is implemented in Visual Assistas the refactoring command "Find References". It highlights all occurences of a given variable or method, but that's not automatic (binded to a keyboard shortcut on my computer).

自动突出显示在Visual Assist 中作为重构命令“查找引用”实现。它突出显示给定变量或方法的所有出现,但这不是自动的(绑定到我计算机上的键盘快捷键)。

Here is an exmaple:

这是一个例子:

alt text

替代文字

回答by Micha

About RockScroll: It doesn't highlight the identifiers. It only highlights the same string in the source code! If there are similar identifier declared : ex. _test and test, and test is highlighted it will highlight the string "test" in variable _test too! And it will also highlight the same string in a method called "sometesting()". So it isn't exactly like eclipse and doesn't work for me.

关于 RockScroll:它不突出标识符。它只在源代码中突出显示相同的字符串!如果声明了类似的标识符:例如。_test 和 test,并且 test 突出显示它也会突出显示变量 _test 中的字符串“test”!它还将在名为“sometesting()”的方法中突出显示相同的字符串。所以它并不完全像 eclipse 并且对我不起作用。

回答by Duncan Smart

DevExpress CodeRushdoes this when you press TAB when the cursor is in an identifier, you can then tab through all the highlighted instances. There's also a DXCore plugin (the foundation upon which CodeRush/Refactor Pro are built) that does current-line highlighting.

DevExpress CodeRush在光标位于标识符中时按 TAB 会执行此操作,然后您可以通过 Tab 键浏览所有突出显示的实例。还有一个 DXCore 插件(构建 CodeRush/Refactor Pro 的基础)可以进行当前行高亮显示。

回答by Duncan Smart

The "error bar" functionality is provided in JetBrains ReSharper. I'm not sure if it does highlighting of references to the currently selected identifier.

JetBrains ReSharper 中提供了“误差条”功能。我不确定它是否突出显示了对当前选定标识符的引用。

回答by wip

For selected word(s) highlight function only, there is also StickyHighlight.

仅针对选定的单词突出显示功能,还有StickyHighlight

StickyHighlight supports Visual Studio 2010 & 2012.

StickyHighlight 支持 Visual Studio 2010 和 2012。