Remove Unused Using in VS 2012 Premium - visual-studio

I am using Microsoft Visual Studio Premium 2012.
Microsoft directions states:
Main Menu - On the Edit menu, point to IntelliSense, point to Organize Usings, and then click Remove Unused Usings.
However, there is no option called "Organize Usings" in the "Intelliense" menu on the "Edit" menu-tab. I can use the context-menu to accomplish this...but that option only appears for a single open code-behind file (when I have it open). Doing so one code-file at-a-time is useless to me in a large project.
Also...
I have looked at other questions for previous version of Visual Studio on this site, and their answers don't work in 2012 Premium.
So my question is...
How can I "Remove Unused Usings" within Microsoft Visual Studio Premium 2012 across a single project or solution?

You would probably have to write a Visual Studio Extension to do this.

You can use the Macro at this link that opens all files of your project and remove unused usings. Otherwise PowerCommands contains some useful extensions, including one that remove all unused usings (never tested it though).

Related

How to disable Edit Project when double click on Visual Studio 2019?

On Visual Studio 2019
When I double click or even focus on project, it open Edit project
For previous version, It just only expand the project structure
How to disable this feature ?
Visual Studio 2019 (version 16.0) introduced the ability to double click on SDK-style projects in Solution Explorer and having them open in the editor.
Based on feedback, an option has been added in Visual Studio 16.1 (currently in preview) that restores the previous behaviour.
If you prefer the old behaviour, uncheck this setting.
EDITORIAL: SDK-style projects are very readable and easy to edit by hand. If you use SDK projects you may start to think of project files as regular source file and that double clicking to edit makes sense. Of course you may not, but it's worth considering.
Here the answer of #Sajeetharan again with a screenshot for a direct way to the setting that currently can be used as a workaround since the accepted answer is not working.
Of course this disables the preview from selected files in the Solution Explorer completely.
Visual Studio 2019 16.3.1:
Yes with VS2019, it is implemented the same way. There is a suggestion opened here
As of now there is no direct way to disable.You can click on the arrow to expand and see the files and structure
In Visual Studio 2022 you can do this as follows:
Go to "Tools"
Select "Options"
Select "Project and Solutions"
uncheck "Open project files with double-click or the Enter key when supported"
Done (see screenshot below)
Screenshot for visual demonstration

Visual Studio files association in Windows

In Windows Explorer when I double-click on any Visual Studio file (*.cs, *.csproj, etc.), it's opening an old version of VS instead of the latest one (VS 2017). And VS has associations with too many file types.
How can I change the default Visual Studio (for all those files that VS can handle)?
There is a similar old question about Visual Studio 2008 (Move file associations from Visual Studio 2005 to 2008) but the solution in there doesn't work anymore (there is no "Restore File Associations" button on the settings of Visual Studio 2017).
Each version of Visual Studio registers itself in the Set Default Programs panel of the Control Panel.
Go to Control Panel\Programs\Default Programs
Then choose Set Default Programs:
In there you can simply choose the Visual studio version of your choice and then click the button Set this program as default in order to associate every file type that VS handles.
Or you might prefer to click the button Choose defaults for this program to review the current associations of those file types and change only the ones you want.
Yet another in a long list of previously working-just-fine things which Microsoft have managed totally #$#%# up. If I try to change defaults the 'right' way I get this kind of thing:
i.e. completely ignored. The only way I've managed to solve it is by removing the file association entirely through the registry. Let's take .asm as an example:
Open Registry Editor / "regedit.exe"
Navigate to HKEY_CLASSES_ROOT\.asm\OpenWithProgIds
Delete any Visual Studio values you see
From there, you can (finally) open files with whatever you choose instead of having the association clamped to Visual Studio:
For the record, I believe this to be a problem with Windows 10. Not with Visual Studio. See: https://answers.microsoft.com/en-us/windows/forum/windows_10-files/cant-change-default-programs-in-windows-10/229fc3a9-25c9-433b-a333-5806bc5090db
On the file you will always open with vs17, click right and choose open with and there choose another app. On win10 it pop out a dialog with some proposals. If vs17 is there, choose your favorite and activate the always open with. then ok and your done.

How to jump to a file in the Source Control Explorer in Visual Studio

I love the Solution Explorer > Right-click > "Open Containing Folder" feature of the PowerCommands extension for Visual Studio 2010. I want the equivalent of a "Jump to location in Source Control Explorer" feature. How can I find out the location in TFS of a given open file, or a file in the solution explorer (or a file in the solution navigator in you have the Productivity Power Tools extension)?
The best answer would be a couple of mouse clicks and no keyboard. Next best answer would be a hotkey mapping.
The only solution that I have found so far is to use the Productivity Power Tools extension which has the feature "Find in Source Control". A file in the results list can be right-clicked to "Open folder in Source Control Explorer". The drawbacks to this solution is that is takes many clicks, and the search results can match more than one file if files exist with the same name in different folders.
There is a stand-alone extension that you can download, called Locate in TFS, within Visual Studio.
"Locate in TFS" on TFS Gallery
"Locate in TFS" on GitHub
This also works on files that you "Exclude from source control", as many developers do with the web.config files.
psulek's post, above, mentions this as part of VSCommands, but I prefer the stand-alone extension.
Try Visual Studio extension VSCommands for Visual Studio 2012. It has feature called Locate in TFS. This will add new button to Solution Explorer Locate in TFS which opens active selected file/folder in TFS Source Control Explorer.
Feature request has been raised with Visual Studio team. Read here
I know it's probably too late. See TfsExt extension for vs2010
I'm not sure if it's possible, but it's a good suggestion.
These two examples show how to use the Visual Studio Extensibility APIs to access the TFS Source Control Explorer APIs.
http://blogs.msdn.com/b/edhintz/archive/2006/02/03/524312.aspx
http://blogs.msdn.com/b/bharry/archive/2008/07/09/working-on-tfs-sdk-improvements.aspx
For Visual Studio 2013 try lightweight extension TfsExt13

VS2010 Only show file names in tabs

My website has several nested folders and sometimes long file names, so sometimes only 4 tabs can be opened at a time.
Can vs2010 be made to show only file names and leave out any path information?
Can the max displayed length for tabs be set?
I know the window can be split so top and bottom both have their own tabs.
For example (using the "Visual Studio 2010 Pro Power Tools"):
Showing the files:
...r.aspx.cs
...s.aspx.cs
...s.aspx.cs
...s.aspx.cs
...s.aspx.cs
For example (not using the Visual Studio 2010 Pro Power Tools):
Showing the files:
Adminstration/...quests.aspx.cs
Adminstration/...tUsers.aspx.cs
Adminstration/...ctions.aspx.cs
Adminstration/...eBanks.aspx.cs
Try installing the "Visual Studio 2010 Pro Power Tools" extension from the Extension Manager in VS. It adds a new section to the standard option dialogue that allows you to customise what they call the "Document Tab Well."
It doesn't let you truncate the filename, but you can change the way they draw and scroll, which might be enough to help.
It does allow more tabs at a time, but it severly shortens the amount of file name you see. So while it allows editing more files, you won't know what file you are editing.
For now I'm using the trial version of Tab Studio
In VS2010, go to Tools - Extension Manager. Go to the online gallery and search for this extension:
Visual Studio 2010 Pro Power Tools
This extension, once installed, gives you extensive control over the document well, including setting a max tab width and much more. I love this extension, and have had zero issues customizing tab behavior to suit my preferences. Hope this helps.
Fixed in Visual Studio 2012
This has finally been fixed in Visual Studio 2012:
So i see:
PendingRequests.aspx (rather than ...r.aspx.cs)
ImportUsers.aspx.cs (rather than ...s.aspx.cs)
SearchTransactions.aspx.cs (rather than ...ctions.aspx.cs)
ImportTimeBanks.aspx.cs (rather than eBanks.aspx.cs)
Now if we could just get the entire Visual Studio ecosystem to:
return to the use of Left, Right arrows to navigate overflow tabs
open new tabs on the right
just like Windows has been doing in 1994, and Visual Studio would start to almost become a user-friendly Windows application.
I have been using this excellent extension for VS2010 that solve your problems: Visual Studio 2010 Pro Power Tools.
It is a bundle of several extensions, but the most notable for you is the Document Well 2010 Plus. It allows you to configure the document tabs: to be the constant width, colour-coded by project, pinned, etc...
You can toggle the extensions that you do not want by editing the manifest file in:
~\Local Settings\Application Data\Microsoft\VisualStudio\10.0\Extensions\Microsoft\Visual Studio 2010 Pro Power Tools\
#IanBoyd: I agree, it doesn't solve the problem 100% however it helps (which is why most of the answers to this question suggest it). With the Visual Studio 2010 Pro Power Tools add-on you can a) set the maximum tab width using one tab options, b) setup some colour categorizing rules to help differentiate between projects/file types.
In VS2010, my workflow relies upon several add-ons and keyboard shortcuts to manage my workspace; for example I use CTRL + Tab to switch between active documents, use the pin-tab feature and colour coding from Power Pro Tools, the open solution file dialog from Visual Assist X, and re-open last edited file from Resharper.
This has been answered already here:
Remove path from tab name in Visual Studio 2010
Install the productivity power tools extension and it should do it by default!
Cheers.

How do you clear your MRU list in Visual Studio?

I want to clear the list of projects on the start page...how do I do this? I know I can track it down in the registry, but is there an approved route to go?
There is an MSDN article here which suggests that you just move the projects to a new directory.
However, as you mentioned, the list of projects is kept in the registry under this key:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\<version>\ProjectMRUList
and the list of recent files is kept in this key:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\<version>\FILEMRUList
Note For Visual Studio 2015:
The location has changed. You can check out this answer for details.
Some people have automated clearing this registry key with their own tools:
Visual Studio Most Recent Files Utility
Add-in for cleaning Visual Studio 2008 MRU Projects list
PowerCommands for Visual Studio 2008
Features
Clear Recent File List
Clear Recent Project List
Clear All Panes
Copy Path
Email CodeSnippet
Insert Guid Attribute
Show All Files
Undo Close
Collapse Projects
Copy Class
Paste Class
Copy References
Paste References
Copy As Project Reference
Edit Project File
Open Containing Folder
Open Command Prompt
Unload Projects
Reload Projects
Remove and Sort Usings
Extract Constant
Transform Templates
Close All
If you try opening up a project that can no longer be found, Visual Studio will prompt you for permission to remove it from the MRU list. So if you temporarily rename an appropriate top level folder to fake the projects' disappearance, you can get rid of the projects one by one.
In Visual Studio 2015 all the history lists (including search history, file MRU and project MRU) are now located at:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\MRUItems
You will see a different GUID folder for each list, and a sub-folder called Items in each of them. Find the Items folder that contains the relevant list, and just delete its parent GUID folder.
Visual Studio will re-create the GUID folder together with a new Items child folder, next time it wants to add something to the list again.
I found the MRU editor from Code Project a great tool for that. No problems with it, and it works on 2003, 2005, and 2008.
Note: This answer is specific to Visual Studio 2010.
If you don't want to manually edit the registry, you can use PowerCommands for Visual Studio 2010.
PowerCommands 10.0 is a set of useful extensions for the Visual Studio
2010 adding additional functionality to various areas of the IDE.
The specific command for clearing the registry from the extension is:
Clear Recent Project List This command clears the Visual Studio recent project list. The Clear Recent Project List command brings up a
Clear File dialog which allows any or all recent projects to be
selected.
The PowerCommands can be installed with the Visual Studio extension manager: Tools > Extension Manager > Online Gallery: search for PowerCommands for Visual Studio 2010.
Try Recently Used Files: a free addin for Visual Studio that manages MRU files on a per-project basis:
Supported for VS 2010, 2012, 2013.
For Visual Studio 2012, 2013:
http://visualstudiogallery.msdn.microsoft.com/a61cbd1d-b5a2-490b-a6bb-f0ea3ecf214a
For Visual Studio 2010:
http://visualstudiogallery.msdn.microsoft.com/45283881-5a62-4dc1-8ffb-4cbc02709947
For Visual Studio 2013:
Open the Run dialog (Press Win + R)
type: regedit
navigate to: HKEY_CURRENT_USER > Software > Microsoft > VisualStudio
click 12.0 then the files will show up on the right side.
Look for the "LastLoadedSolution", right click then click Modify
change the value to 0.
This worked for me.
I'm not sure if this solution has been posted somewhere here, but if you have VS 2013 Update 5 you can open start page, and right click project below "Recent" list, and choose "Remove from list". I don't know how about other VS versions, maybe this feature is available.
I had this issue as applied to VS 2017 where you do not have any MRU items in the registry as in the previous versions. The solution was, on the other hand, simple: go to "Tools->Extensions and Updates" and install "Power Commands for Visual Studio". After they have been installed, your File menu will look as shown below.
Just click the menu item to clear the project MRU.

Resources