Finding occurrences of a method or variable in Visual Studio - c#

So I've been working with Visual Studio 2010 lately. While I'm not a huge fan of Eclipse, I do miss one feature: the fact that if you click on a function or variable in your code, it will mark all occurrences of that thing on the right frame of the text editor with a yellow or white rectangle. Does such a feature exist in Visual Studio? If not, is there a plugin out there that'll do this? I really don't want to resort to Find All every time I need to keep track where something is used.

Highlight References is feature in Visual Studio 2010 for C# and VB only. Any time you place the blinking caret on a symbol, Visual Studio will automatically highlight all instances of that symbol for you You can actually cycle through these highlighted references – just use Ctrl+Shift+up arrow and Ctrl+Shift+down arrow to move to the previous or next highlighted symbol.

The ProductivityPowerTools is what you may need. There you have a bar where you can see a minimized view of all your code. If you click there you can also navigate your code. But if you click within your actual code on a member, all occurences of this member are shown in the map.

Press Ctrl-K then Ctrl-R, this will find all references to the method (or object, variable, etc.)

Related

Gray code in partial files where suggestions are presented

I'm using Visual Studio 2019 and it grays some of my variables in my codes that weren't grayed in Visual Studio 2017.
For example, if I write "Variable = null" (assuming the specific Variable is already declared and has a value inserted inside) then it grays it and suggests to delete that line.
These suggestions are destructing me, and annoy my eyes as the color of the codes keep on changing.
How can I disable those specific suggestions (and not disabling suggestions totally) or at least not allowing it to become light gray, changing its color to black or not letting it effect the previous color.
How can I disable those specific suggestions
You can disable the suggestion (not just the formatting, but the actual suggestion itself) by clicking the lightbulb icon in the gutter of the editor window (), and choosing the "Configure or Suppress issues" menu item in the popup menu.
For the issue you're asking about, "Remove unused members", that's IDE0051. Select the "Suppress" menu item for that issue, and choose from one of the three options. For keeping the code file itself clean, using the "in Supression File" is best. It will track that particular line of code, but in a separate file, out of the way of the code itself.
Color Theme Designer plugin can solve the problem.
The light gray colour of text can be changed to a colour of choice using this free plugin.
Color Theme Designer can be downloaded from
https://marketplace.visualstudio.com/items?itemName=ms-madsk.ColorThemeDesigner
I haven't found a solution, but I've found something that will be useful for me, perhaps a bug in visual studio 2019 basic themes.
The theme Blue (Extra Contrast) color of the text that's supposed to be grayed - isn't getting grayed, infect it's effected only by the setting of User Members - Locals (and perhaps other user member types, but the colors depend on them and the text isn't getting grayed).

Visual Studio 2012/2013 Navigation Back/Forward with Mouse confliting with Mouse Plugin

The Navigate Backward (Ctrl+-) and Forward (Ctrl+SHIFT+-) buttons on the IDE use to be controlled by the mouse lateral Back/Forward buttons in VS 2010.
In VS 2012, the mouse buttons only works in some cases, like going back after clicking in "Go To Definition" in a method call. They are not attached to the IDE buttons.
Trying to fix that, I've installed this plugin: Mouse Navigation
Well, it works fine until you use the "Go To Definition", after that, the embedded VS Back/Forward mouse functionality start to conflict with the plugin, resulting in messy behavior!
Am I the only one with this problem? I've tried to Google it, but I've found nothing.
This is really annoying! I hope someone can help me to solve that.
Edit:
As you can see at the marked answer, the plugin have been fixed by its developer thanks to this topic. The last version (2.2.0) is working fine.
Some clarifying:
Visual Studio (2012) separates the normal navigation from "click to go" navigation.
Normal navigation: mouse click anywhere in code editor, tab change also.
Click to go navigation: Go to definition, search result click. It is controlled by the buttons named: "Browse Back / Next" "Previous/Next Definition, Declaration or Reference". You can find it in the View custom toolbar.
The default VS mouse back/forward buttons are attached to the "Browse Back / Next" buttons, not to the Navigate back/forward.
The VS plugin Mouse Navigation sets the mouse buttons to the Navigate back/forward. The only remaining problem is that because VS doesn't consider "click to go" as normal navigation, when you click to go to a definition and try to go back using the Ctrl+- or mouse back, you will not return to the last position, but to the previous "Normal navigation" position.
My suggestion to the plugin developer is to try to make VS consider "click to go" navigation as normal ones, completely solving this issue.
I just updated the Mouse Navigation extension to improve reliability of the commands. For some reason I never updated the extension to properly use the new IMouseProcessorProvider interface when I migrated from Visual Studio 2008 to Visual Studio 2010, and that bug never bothered me enough to revisit the extension until today.
You should find that version 2.1.0 behaves properly in Visual Studio 2010-2013.
The reason it only half works without the plug-in is because the mouse forward/back buttons do not map to navigate forward/back but rather some other navigation command (which never made sense to me as to what it was doing).
The way I solved this problem is to use my mouse software (SetPoint from Logitech in my case) to bind mouse forward/back to CTRL+SHIFT+- and CTRL+- respectively, while Visual Studio is in the foreground. This leaves my back/forward buttons working correctly in other applications (web browser) but while in Visual Studio I get the expected functionality.
Also, Visual Studio 2013 does seem to have better mouse back/forward control... though I haven't been using it long enough to be able to say whether the problem is truly fixed.

Cursors stays where I click in VS text editor

Sorry for question but I can't find answer anywhere on internet. I couldn't find answer myself either. Here is question:
Previously when I clicked anywhere in VS text editor cursor moved to the end of statement, just after ";". But now it stays where I click on the screen and it is really annoying. How can I address this issue. Thanks in advance.
This is called Virtual Space and can be changed in Visual Studio's options dialog.
As per the MSDN article:
To position comments beside your code
In the Options dialog box, expand Text Editor, and then click the
General node for your development language.
Under Settings, select Enable virtual space.
When this option is selected and Word wrap is cleared, you can click
anywhere beyond the end of a line in the Code Editor and type.
To revert to the behaviour you're after, you need to uncheck Enable virtual space either at the language level or for all languages:
Also more here.
In Visual Studio 2019, you must check the Tools - Options -Text Editor - All Languages - Scroll Bars then check the Show caret position option.

Is there a way to highlight the currently active code block in Visual Studio 2010?

In Visual Studio 2010, if you hover your mouse over the little [-] minus sign, it will highlight that block of code for you. My question is, is there a way for this block to always be highlighted while you are coding inside of it? That way, as I'm hopping between methods and classes, whatever block I'm currently working on would be highlighted to help my eyes quickly focus.
Is there an option within Visual Studio for this? If not, are there any plugins that do this?
Resharper has some options for this, one will let you outline the braces you are currently in and I think the other lets you highlight the current line
ReSharper is nice, but if you're also looking for something for all kinds of languages, there is Visual Assist X, which also does nice highlighting.
It, too, has the option to highlight matching braces in your current block:
Then you have a line highlighter, either as a simple frame:
Or as a good looking background:
Sadly, there is no option in it to enable a real "block" highlighting like hovering over the [-] button does. :| I also looked for, but didn't find such an option within the Visual Studio options.
Highlight everything you want your eyes to focus on and press ctrl+H.
Or, highlight everything you DON"T want and right click "Outlining" then select "Hide Selection." The short cut for that is ctrl+M
This can be done using bookmarks. The out-of-the-box configuration of bookmarks does not highlight, however this can be changed easily:
Go to Tools – Options – Environment – Fonts and Colors. Under Display Items, select Bookmark. Now change the background color to something, like red. Then go to Tools – Options – Text Editor – General and uncheck Indicator Margin.
PS Bookmarks can be found in the Text Editor toolbar
PS2: To quickly set bookmarks use Ctrl+k+k, but beware of Ctrl+k+l which will wipe out all your bookmarks, it happened to me once!
Adapted from: http://blogs.msdn.com/b/saraford/archive/2007/09/05/did-you-know-how-to-change-a-bookmark-color.aspx

How to get an Eclipse-like class outline in VS 2008/C#?

I've just recently started using VS2008 for a new tools project, and have been spending a lot of time in Eclipse/Java. The one thing I am missing is the thing I could have sworn was in VS2005 the last time I worked with it - the class outline.
I'm speaking of the basic outline in Eclipse, where you can see the class members, methods, etc and click on them to navigate to them.
The only thing that sounds like it might be it (but is not) is the Class View.
Any help?
This is probably the closest addin that you'll find that has it:
Source Code Outliner Power Toy
(The window on the left is what it adds to Visual Studio)
alt text http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=SourceCodeOutliner&DownloadId=3493
"You can dock the Source Code Outliner anywhere, like to the left side of the Visual Studio window next to the Code Editor window."
"Click a method or variable name in Source Outliner and the code associated with what you clicked displays near the top of the Code Editor window."
JetBrains Reshaper.
This is what I had to do:
Open the Object Browser (View->Object Browser). It will open as a tab.
Right click the tab and select the "dockable" option. Then it will open as a window floating around.
I have 2 monitors, so in one of them I have visual studio, and in the other I put the Object Browser window. If you click something in the Object Browser, it will take you to where it is defined in the visual studio editor.
Not the same as the Eclipse outline (I miss it too), but this is the closest to it I'have found without adding pluggins.
Try this menu option:
View > Class View
The default keyboard shortcut is
Control + Shift + C

Categories