Code Window does not highlight selected (usually .cs) file in "Solution Explorer" - visual-studio

My Visual Studio has done something really weird.
Usually, when you are in the "edit window" and are changing code, the file you are editing will highlight in "Solution Explorer".
Also, if all projects are "collapsed" in "Solution Explorer", and then there is a file already open (as in, you can see its "tab"), when you click the tab of that file (to be able to edit it), the Solution-Explorer will un-collaspse that project and highlight the file you are editing.
My "Solution-Explorer-Highlight-The-Current-File" function has stopped working.
I can move from tab to tab to tab, and Solution-Explorer doesn't react at all.
I've googled and binged, and I either get 5 billions hits ... or none. The key phrases are too ambiguous I think.
Anybody ever seen this one?
I have VS2010 on the same machine, and it works just fine.
I have one Add-In installed, but it is installed in both VS2010 and VS2012. Thus I don't think it's the culprit.

Smaller hammer.
From the menu: Tools -> Options
From the tree: Projects and Solutions -> General
On the form check: Track Active Item in Solution Explorer

Well.
From here:
How do I truly reset every setting in Visual Studio 2012?
I found this "Big Hammer" command line switch.
/ResetUserData
I used it.
And now it works.
I hate to answer something myself, but just in case somebody hits this in the future.

Related

Is there a way to automatically collapse the Script Documents section in solution explorer?

While in debug mode, the solution explorer has a Script Documents section. It is expanded by default. As the debugger runs, new ScriptDocumentxxx poll.txt files are added to this section. As I am navigating the explorer files, the adding of these new line items causes the entire contents of the explorer to shift downward. This is quite annoying if I am trying to find a file or trying to click something. I can collapse the section manually, but I'd rather not have to do this all of the time.
Right click the projects you are interested in working on and click on 'Scope to this'. This will hide everything (Including the scripts folder) except those projects you selected.
I got annoyed enough with this that I turned off JavaScript debugging. If you are willing to go that far, the scripts are gone.
The path for turn of JS debugging is:
Tools -> Options -> Debugging -> General -> Enable JavaScript debugging for ASP.NET (Chrome, Edge and IE) (Visual Studio 2017 and 2019)
Note: This method does not prevent you from stepping though JS in the Chrome inspection tools so you do not lose that ability. You lose both the scripts (of course) and that new Chrome window that pops up when you launch the debugger.
Yes, there is.
IIS Express > Script Debugging > Disabled
Right click then 'Scope to This' to hide everything but the project in the solution you want to view.
Click on the Home/House icon to reverse it.
Yes there is. One way is to create a visual studio add-in or extension which monitors the solution explorer tree and collapses the "script documents" -item if it is expanded.
If you need code samples and/or a fully functional add-in just let me know. You have Visual Studio 2013, ay? Is it the express edition or what?
This is confirmed bug in VS 2019. Just Microsoft is not so fast about fixing it.
https://developercommunity.visualstudio.com/content/idea/351537/provide-a-way-to-prevent-the-script-documents-fold.html

How to avoid automatically unfolding of projects in Visual Studio 2010 Solution Explorer

I have all the projects in a solution folded, so you can't see their files in the Solution Explorer. And a file belonging to one of those projects open. Once I browse to that file pane, the project containing the file is automatically unfolded in the Solution Explorer.
Is there a way to avoid that automatic unfolding?
I'm not 100% sure what you're after, but in the VS 2010 options, under "Projects and Solutions/General" there is an option called "Track Active Item in Solution Explorer".
I've just tried unchecking that and, with a mutiple project solution all collapsed, when clicking into an open code file it doesn't open up the project in the solution window. Try that and see if it produces the result you're after.
Let me know if I've misunderstood your question though!

ReSharper 5.1 can't navigate to a type from anywhere

I'm running Visual Studio 2010 (10.0.40219.1 SP1Rel) with ReSharper 5.1 (5.1.3000.12). Recently, it seems as though ReSharper has completely lost the ability to navigate to a type.
Here are some actions I can take in the UI that now do nothing:
Right-click on type name in code
editor and select "Go To
Declaration"
Right-click on type name in code
editor and select "Go To
Implementation"
R# "Go to type" (Ctrl-T)
In the R# "Find Results" window, double-clicking a type
Here are some actions that still work:
Double-clicking an item in Solution Explorer
Opening a file from VS Command Window
I've completely uninstalled Visual Studio, then reinstalled it with SP1, and ReSharper 5.1, and I still have the same problem.
I'm assuming there's some kind of configuration open that I've done that is disabling the ability to navigate to a type with ReSharper, I just can't figure out what it is.
Any advice would be much appreciated.
I just experienced this problem. None of the previous suggestions worked for me unfortunately, but I managed to resolve it:
Go to Resharper -> Options
Under Keyboard Shortcuts, temporarily switch to a different scheme than the one selected
Press 'Apply Scheme' button then press Save
hen repeat, but this time select the scheme you actually want and press 'Apply Scheme'
Hopefully that fixes it!
I am using VS 2010 SP1 (same as you)
Delete the Resharper temp files in the same location as your solution file. The folder name will be something like _ReSharper.SomeSolution
Failing that, try one of the R# nightly builds here altho it should work with your current config.

How to locate a file in Solution Explorer in Visual Studio 2010?

I have a huge solution with multiple projects. Sometime I need to navigate to a file in Solution Explorer. Using the VS 2010 'Navigate To' feature I can open any file by name in Visual Studio 2010 but I want to be able to select the file in Solution Explorer as well?
There's an option to track the active (open and viewed) item in the solution explorer. If the file is in view, the file in the solution explorer will be selected.
Tools->Options->Projects and Solutions->Track Active Item in Solution Explorer
VS2012 added a new command called SolutionExplorer.SyncWithActiveDocument. The default shortcut for c# is Ctrl+[,S
This command will navigate to the active file in the Solution Explorer.
Also, it seems that you need to have the "Track Active Item in Solution Explorer" option turned off.
With ReSharper installed Shift+Alt+L will find the current file in Solution Explorer in Visual Studio 2008+.
I found the track option to be a little annoying.
I prefer to use DPack. It contain "Locate In Solution Explorer" operation, plus many other features (some are less powerful in VS2010, like their browsers), and it's free.
Note that ReSharper also have the locate feature that works batter than DPack's (in some cases, DPack's locate won't work if the file is collapsed behind folders), but you don't want to buy ReSharper only for this feature.
Brian Schmitt has a great Locate File in Solution Explorer – Visual Studio Macro post for this. The macro is extremely simple and quick. Basically it toggles the setting
Tools->Options->Projects and Solutions->Track Active Item in Solution Explorer
so that the current file ends up selected in the Solution Explorer but, because it is not left on, you don't get irritated by Solution Explorer nodes being expanded for all the files you access.
Public Sub LocateFileInSolutionExplorer()
DTE.ExecuteCommand("View.TrackActivityinSolutionExplorer")
DTE.ExecuteCommand("View.TrackActivityinSolutionExplorer")
DTE.ExecuteCommand("View.SolutionExplorer")
End Sub
Bind a Keyboard ShortCut to this custom macro to effectively create what should be a built-in Visual Studio feature.
If you have ReSharper and want to add "Locate in Solution Explorer" to the tab's context menu:
Go to Tools -> Customize -> Commands -> Context Menu
Select "Other Context Menus | Easy MDI Document Window".
Click "Add Command".
Choose "Resharper" -> "ReSharper_LocateInSolutionOrAssemblyExplorer" (in VS2019, the category name was changed to "Extensions")
"OK" -> "Close"
Now, when right click on any tab and you'll see a new option: Locate in Solution Explorer.
UPDATE:
Following the comment from #jeremy-paskali, you can set a keyboard shortcut for this command:
Go to Tools -> Customize -> "Keyboard..."
Search for "ReSharper.ReSharper_LocateInSolutionOrAssemblyExplorer" in the "Show commands containing" field and select it.
Review the currently assigned shortcuts in the drop down below.
Make any changes, if needed.
"OK" -> "Close"
Visual Studio 2012 has a new shortcut Ctrl [, S. Yes you have to type Ctrl [ and then release and then immediately type S (or click the little sync icon at the top of Solution Explored). It will synchronize to the item.
Of course you can change the shortcut. I think I'll try Alt+L for locate.
If you want to change the shortcut, it's command name under Options\Environment\Keyboard is SolutionExplorer.SyncWithActiveDocument.
Usually this is more useful than always tracking, which in older versions always was a disaster because it would track 100 items in a row and then be jumping all over the place...
I know its little too late, but hope it helps someone else. The best option now is to install Microsoft Visual Studio add on called - Productivity Power Tools.
http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef
With this comes "Solution Navigator" (alternative to Solution Explorer, with a lot of benefits) - which then you can use to filter the files to only show "Open". You can even filter files to show "Edited" and "Unsaved".
In the event you want to only track the current file through a
keyboard shortcut - the activity is
"View.TrackActivityinSolutionExplorer" (assign keys here -> Tools -
Options - Environment - Keyboard)
Credit (James' comment)
This worked for me
There are several build-in ways you can accomplish this nowadays:
Configure VS to track the active item in Solution Explorer: This can be accomplished by selecting "Track active item in Solution
Explorer" at
Tools > Settings > Projects and Solutions > General
Use "Sync with active document": This can be accomplished in 2 ways.
Firing the SolutionExplorer.SyncWithActiveDocument command by using the default key combination CTRL+]+S
CTRL+)+S if you happen to be using an AZERTY keyboard like me.
By using the "Sync with active document" button on top of the Solution Explorer. The button looks like 2 apposing arrows on top of each other.
If you're version is older then VS2019 Version 16.10.2 then this button looks like this:
From VS2019 Version 16.10.2 onwards this button will look like this:
And yet again Microsoft has changed the button icon in more recent versions of VS 2022:
In Visual Studio 2010 you can turn on the "Track Active Item in Solution Explorer" option. This will mean whenever you switch between documents the new document gets selected in Solution Explorer. This can be irritating if your solution has lots of folders, because as you move around files in your solution all the folders will be left open.
Visual Studio 2012 introduced the new "Sync with Active Document" feature. Three is a button for it at the top of Solution Explorer, or you can use the shortcut Ctrl + [, S.
This is actually built in to visual studio without the need for ReSharper (which I love BTW).
http://blogs.msdn.com/b/zainnab/archive/2010/03/29/track-active-item-in-solution-explorer-vstipproj0011.aspx
If you want to select the file in the solution explorer on command and don't want to install anything then I would recommend this macro.
I've tested it, setting the shortcut to Alt+T, and I can confirm that it works with VS 2010.
Thanks to Dan Vanderboom for writing it.
For Visual Studio 2017 using a French AZERTY keyboard the command is the same as stated by Aaron Carlson but the keyboard shortcut is different.
The AZERTY keyboard shortcut to navigate to the active file for c# is Ctrl+),Ctrl+S
I checked the shortcut hadn't changed for QWERTY users in VS2017 on this page
http://visualstudioshortcuts.com/2017/
Visual Studio doesn’t offer an easy way to locate the current file you’re editing in the Solution Explorer on demand. You can set the solution explorer to always stay in sync with this simple setting:
Tools > Options > Projects and Solutions > General. Check “Track active item in Solution Explorer”.
Thanks to Cory House

Visual Studio Editor does not underline errors anymore

My Visual Studio (2008) Editor has stopped to underline Errors (this nifty wavy red lines). I can't really tell when, but it can be related to the installation of .Net Framework 3.5 SP 1 or the MVC Beta (which I guess is unlikely). Furthermore have I installed and uninstalled both CodeRush and Resharper for evaluation purposes (decided not to keep either one of them).
Does anyone know the problem and how to restore this functionality again?
Have you checked Tools→Options...→Text Editor→C#→Advanced→Underline errors in the editor?
I usually like to reset my settings after messing around with plugins, as they tend to mess with settings: Tools→Import and Export Settings...→Reset all settings.
About possible causes.
For VS 2012 and 2013 if you have more than one instance of Visual Studio on different machines binded to one "live" account and have installed ReSharper on one of them, it disables the native IntelliSense and error underlines (to replace by it's own rules) that will be synchronised through your account to another machine without ReSharper.
Found it in Visual Studio 2019 as: Tools > Options > Text Editor > General > Show error squiggles
This is generally called Disable Squiggly or Wavy lines in Visual Studio.
How you will do in Visual studio 2013?
TOOLS -> Options... -> Text Editor -> C/C++ -> Advanced -> Disable Squiggles: True/False (Under IntelliSense) -> Press OK
I know its an old question, and with various solutions, but I have fixed it in different way. I'm working with Unity3D on my C# code using VS2017, when suddenly VS decides to stop underlining error while im typing. However, if I close the file tab and reopen, it suddenly undelines the error.
For example:
class A {
public int x;
s;
}
should obvsiouly give an error for that lonely 's' symbol. But, VS doesn't underline it until I close and reopen this file tab.
Solution:
Copied the entire Unity Project folder (which is like a regular VS Solution folder basically) and worked with the new folder, which issue was gone there.
For visual studio 2017 act according to HeeJae's comments in:
https://developercommunity.visualstudio.com/content/problem/113112/design-time-error-checking-isnt-working.html
i.e:
Hi. you are probably hitting a known issue. can you try this?
1.Update to latest release If that doesn’t solve it
2.Go to Tools\Options\Projects and Solutions\General and uncheck “Allow parallel project initialization”.
3.Close VS.
4.Delete the “.vs” directory beside their solution file.
5.Reopen VS.
..
thank you
You can re-enable the "Allow parallel project initialization" option after the issue was solved.
I tried to upgrade VS, reset VS settings, clear VS cache and everything people do conventionally but none of them solved this issue! At the end the mentioned solution worked for me magically.
Good luck
Unloading and loading same project again from the solution does the trick. Just right click on the project and click "Unload Project". Once unloaded, again right click the same project and click "Reload Project". Error highlighting will return.
I had the same issue with 2017. There was a 'disable intelisense' option, make sure that is set to false.
For everyone wondering in 2021..
search for "C_Cpp.errorSquiggles" in the settings.
Make sure to have it active for the user, as well as the workspace.
No need to restart Visual Studio.
For me (VS 2019) , after trying the other answers also, setting the scope of analysis from "Current document" to Open document" brought back the missing error markers
Just go to settings and search for errors and Image in Error Squiggles. You can see the Error squiggles (Modified: Workspace - Right now you can't see it because I modified it). Just click on modified and you will see the disabled option. If by mistake you disabled it, just enable it and you can see the red line errors again in your code.
In latest edition, check for .vscode folder in same project folder. There will be a setting.json file in that. Delete the key value pair of "C_Cpp.errorSquiggles": "Disabled". Restart the vs code.

Resources