Visual Studio(或resharper)变量和方法着色

时间:2021-09-30 00:37:41

Ok, I am not sure what the naming for this is actually called, but I would like to know if the following is possible in Visual Studio.

好吧,我不确定实际调用的命名是什么,但我想知道在Visual Studio中是否可以使用以下命令。

When I set my cursor on or highlight a variable, or method name, or string... etc, I would like the IDE to highlight all uses of it. So if I highlight variable x, then it highlights all other uses of variable x.

当我设置光标或突出显示变量,方法名称或字符串...等时,我希望IDE突出显示它的所有用途。因此,如果我突出显示变量x,那么它会突出显示变量x的所有其他用法。

This is done in eclipe and Notepad++, and I have become very fond of that feature, but when I move to VS, I cannot seem to get that functionality.

这是在eclipe和Notepad ++中完成的,我已经非常喜欢这个功能,但是当我转向VS时,我似乎无法获得该功能。

I know I can use the right click and find definition, also I can use resharper to find all uses, but that is not as easy and intuitive. I am currently using VS2008, but would like it in both 2008 and 2005.

我知道我可以使用右键单击并找到定义,我也可以使用resharper来查找所有用途,但这并不容易和直观。我目前正在使用VS2008,但在2008年和2005年都希望如此。

Also, if this is a feature of resharper that I just don't see, that is good too.

另外,如果这是我看不到的resharper的一个特征,那也很好。

Thanks

6 个解决方案

#1


With Reshaper you can press Shift+Alt+F11 when your cursor is inside a variable to highlight all usages of that variable in that file. (Then ESC to remove the highlighting)

使用Reshaper,当光标位于变量内时,可以按Shift + Alt + F11以突出显示该文件中该变量的所有用法。 (然后ESC删除突出显示)

#2


This is not a feature of Visual Studio 2008 or previous versions. It will be a feature of Visual Studio 2010 though.

这不是Visual Studio 2008或以前版本的功能。但它将是Visual Studio 2010的一个功能。

#3


With ReSharper, if you're using the IDEA keybindings, use Ctrl+Shift+F7. If you're using the VS keybindings, use Shift+Alt+F11 (like Martin Harris said).

使用ReSharper,如果您使用的是IDEA键绑定,请使用Ctrl + Shift + F7。如果您正在使用VS键绑定,请使用Shift + Alt + F11(如Martin Harris所说)。

You can find the full map of keybindings here: ReSharper Feature Map

您可以在此处找到完整的键绑定地图:ReSharper功能图

#4


A VS plugin that I use, WholeTomato's Visual Assist X, does this. If the thing being highlighted is a variable, it will even show assignments and reads in different colors.

我使用的VS插件WholeTomato的Visual Assist X就是这样做的。如果被突出显示的是变量,它甚至会以不同的颜色显示赋值和读取。

#5


DevExpress Refactor or Code Rush (I have both, so I'm not sure which) will do this.

DevExpress Refactor或Code Rush(我有两个,所以我不确定哪个)会这样做。

Place the cursor on a variable and hit tab; all uses of the variable that are in scope will be highlighted.

将光标放在变量并点击标签上;将突出显示范围内变量的所有使用。

#6


In Visual Studio, have the variable selected(you can also select methods etc.), then in the top menu go to Resharper -> Find -> Highlight Usages in File or press Shift + Alt + F11 on the keyboard.

在Visual Studio中,选择变量(您也可以选择方法等),然后在顶部菜单中转到Resharper - >查找 - >突出显示文件中的用法或按键盘上的Shift + Alt + F11。

Then if you want you can navigate down trough the usages with Ctrl + Alt + PgDn and upwards with Ctrl + Alt + PgUp.

然后,如果您需要,可以使用Ctrl + Alt + PgDn向下导航,使用Ctrl + Alt + PgUp向上导航。

#1


With Reshaper you can press Shift+Alt+F11 when your cursor is inside a variable to highlight all usages of that variable in that file. (Then ESC to remove the highlighting)

使用Reshaper,当光标位于变量内时,可以按Shift + Alt + F11以突出显示该文件中该变量的所有用法。 (然后ESC删除突出显示)

#2


This is not a feature of Visual Studio 2008 or previous versions. It will be a feature of Visual Studio 2010 though.

这不是Visual Studio 2008或以前版本的功能。但它将是Visual Studio 2010的一个功能。

#3


With ReSharper, if you're using the IDEA keybindings, use Ctrl+Shift+F7. If you're using the VS keybindings, use Shift+Alt+F11 (like Martin Harris said).

使用ReSharper,如果您使用的是IDEA键绑定,请使用Ctrl + Shift + F7。如果您正在使用VS键绑定,请使用Shift + Alt + F11(如Martin Harris所说)。

You can find the full map of keybindings here: ReSharper Feature Map

您可以在此处找到完整的键绑定地图:ReSharper功能图

#4


A VS plugin that I use, WholeTomato's Visual Assist X, does this. If the thing being highlighted is a variable, it will even show assignments and reads in different colors.

我使用的VS插件WholeTomato的Visual Assist X就是这样做的。如果被突出显示的是变量,它甚至会以不同的颜色显示赋值和读取。

#5


DevExpress Refactor or Code Rush (I have both, so I'm not sure which) will do this.

DevExpress Refactor或Code Rush(我有两个,所以我不确定哪个)会这样做。

Place the cursor on a variable and hit tab; all uses of the variable that are in scope will be highlighted.

将光标放在变量并点击标签上;将突出显示范围内变量的所有使用。

#6


In Visual Studio, have the variable selected(you can also select methods etc.), then in the top menu go to Resharper -> Find -> Highlight Usages in File or press Shift + Alt + F11 on the keyboard.

在Visual Studio中,选择变量(您也可以选择方法等),然后在顶部菜单中转到Resharper - >查找 - >突出显示文件中的用法或按键盘上的Shift + Alt + F11。

Then if you want you can navigate down trough the usages with Ctrl + Alt + PgDn and upwards with Ctrl + Alt + PgUp.

然后,如果您需要,可以使用Ctrl + Alt + PgDn向下导航,使用Ctrl + Alt + PgUp向上导航。