Visual Studio - Shortcut to Navigate to Solution Explorer - visual-studio-2010

Is there a keyboard shortcut in Visual Studio (aside from CTRL+TAB and selection) that would take me from inside a document directly into the solution explorer? I don't want to customize any shortcuts or change any default behavior.

CTRL+ALT+L
should shift focus to the Solution Explorer.
For visual studio 2012 use:
CTRL+[ + S this selects your current document in the solution explorer.

When using VS 2012 with the Visual C# 2005 keyboard mapping scheme:
CTRL+W, S
I find this easier to memorize: All shortcuts beginning with CTRL+W are for opening or navigating to W indows:
CTRL+W, S: S olution Explorer
CTRL+W, E: E rror list
CTRL+W, R: R esourceview
CTRL+W, A: Command window (A ction ...)
CTRL+W, T: T askview
CTRL+W, Q: Find Symbol Results
CTRL+W, X: Toolbo x
CTRL+W, C: C lassview
CTRL+W, P: P roperties
CTRL+W, B: B ookmarks
...

In Visual Studio 2012 you can now use CTRL+; as this is the default keyboard shortcut for the solution explorer search box.

On my windows 7 machine : Ctrl+ALT+L locks the computer.
For me
: Shift+ALT+L
works. (This could also be a resharper configuration)

shortcut ctrl [, S will focus current open file/document in solution explorer.
setting checkbox to true in "Track active in Solution Explorer" will automatically focus current open file/document in solution explorer (Tools->Options->Projects and solutions->General->"Track Active Item in Solution Explorer"=true

The default keyboard shortcut for opening/jumping to Solution Explorer is Ctrl + Alt + L.

Extended above : command name for sync tab with solution explorer is "SolutionExplorer.SyncWithActiveDocument"

Visual Studio
2015 and 2017 (by default) VS 2017 Shortcuts
Ctrl + [, S
Runs Keyboard Shortcut
SolutionExplorer.SyncWithActiveDocument
ReSharper
In Visual Studio 2015 and 2017 (by default) Resharper Docs
Shift + Alt + L
Which runs Resharper's Keyboard Shortcut
Resharper.Resharper_LocateInSolutionOrAssemblyExplorer
Both
Focus Solution Explorer
Highlight document
Scroll / expand nodes (as required to show that document)
Difference
Resharper's version also works with decompiled code. Locating decompiled symbols in the Assembly Explorer window.
To customise / it doesn't work :
Tools > Options > Environment > Keyboard
Search shortcut name (e.g. SolutionExplorer.SyncWithActiveDocument)
Assign (in Global) to Keyboard shortcuts as you like

I had this problem on a new machine build with VS 2013 and R# 8.2.
Keyboard option Resharper.Resharper_LocateInSolutionExplorer was correctly set to Shift+Alt+L, but it seemed to be only opening a parent folder and not selecting the actual file. As recommended in another post I enabled "Track active in Solution Explorer" in the VS Options.
This didn't fix the problem and wasn't what I want because in very large solutions I don't want the solution explorer jumping around to the current file in use. I disabled the Track feature and restarted VS, the LocateInSolutionExplorer feature then started working correctly. Some sort of shortcut precedence issue?

ctrl + [ + S.
This shortcut will highlight the currently opened document in solution explorer.

For AZERTY keyboards like mine, the default shortcut is Ctrl+), Ctrl+S

Ctrl+Alt+L works fine even in VS 2019.
But if you have reassigned the above key to some other command (by mistake in my case) then the name of the command is View.SolutionExplorer
You can search it in the Tools -> Options -> Environment -> Keyboard
or just do Ctrl+Q and search keymap.
And then search View.SolutionExplorer in the Show commands containing: and assign whichever key you want.

We just upgraded from VS2013 to VS2017, and I had to go looking for how to auto-select the active tab in the Solution Explorer. I often have to look for a document by finding a text-string from a screen, and love to have it select the document so I can see where it is.
Tracking the active document has been default behavior for a long time. VS2017 brought over ALL my other preferences, but not this one. Glad I found this thread--Thank you.

Related

Visual Studio: Shortcut to close window not working

I changed the shortcut to close a window to Ctrl+W and to close all windows to Ctrl+Shift+W. Close all windows works fine, but Ctrl+W selects the word currently under the cursor but does not close the window.
When I right-click a tab it say Ctrl+W is the shortcut to close it (And also Ctrl+S to save and Ctrl+Shift+W to close all). Why is only the close window shortcut not working?
In Visual Studio (VS 2015 in my case but it's similar down to VS 2010 at least) keyboard shortcuts may have a different meaning depending on the context in which they are executed.
Click Tools / Options / Environment / Keyboard to look up or define shortcuts (you already did that probably). What I called "context" is selected in the combobox labelled "Use new shortcut in:". Most likely you defined the shortcut in "Global" but you want it to work in "Text Editor". In the latter Ctrl+W selects the current word.
Redefine Ctrl+W for "Text Editor" and you should be fine.
I am using Visual Studio 2017 & Visual Studio 2019 and tried the answer from #TobiMcNamobi but it didn't work for me. After few such tries I got it work with below steps.
You should add it as Global shourtcut otherwise it will not work for Designer views.
Add CTRL+W as a Global shortcut for Window.CloseDocumentWindow
Remove the CTRL+W shortcut for Edit.SelectCurrentWord
In Visual Studio 2019 it is Ctrl-F4 by default to CloseDocumentWindow. The action is Window.CloseDocumentWindow. I know this is old but the accepted answer has you change the short-cut key instead. I would rather use the default option.
Tools -> Options -> Environment -> Keyboard
If you're ever unsure go to the path above and you will see the image above then you can click inside the box "Press shortcut key" at the bottom of the form and type the short cut key you're interested in and it will tell you if it is used and what it is currently used for.
You can also reference the docs
https://learn.microsoft.com/en-us/visualstudio/ide/default-keyboard-shortcuts-in-visual-studio?view=vs-2019
2021: For Visual Studio 2019:
See: https://gist.github.com/jpoehls/2030795#gistcomment-2335647
In my case, I had to existing assignments that I had to remove. Thereafter, I could use the hotkey.
In my case, the tabs were not closing because I am using Vim extension. I had to add the following lines to Vim settings:
"vim.handleKeys": {
"<C-w>": false
}
Just press Ctrl + , or Command + , for Mac users, search for Vim and go into Edit in settings.json as the following picture shows:
Screenshot
For Visual Studio 2022, make sure you also remove Ctrl+W from selectCurrentWord command.
In my VS Pro 2019, on Tools / Options / Environment / Keyboard, the first line offers using a premade keyboard mapping scheme, with a drop-down option for VSCode keyborad mapping theme.
I picked it and it seems to have adopted the keyboard shortcuts I was used to from working on VSCode, Ctrl+W included.
For those using linux with VSCode v1.56.2,
File --> Preferences --> Keyboard Shortcuts.
Search for View:Close Editor and as mentioned above, remove any keybinding that has the keybinding you want.

Visual Studio: Shortcut Info

for some/most of the functions in Visual Studio there do exist shortcuts. Sadly it's hard to find them.
I'm looking for a addin/tool that will display me information for a shortcut.
For example:
I comment a line with // and the tools gives me information that the shortcut for this is STRG + K, C.
I press some button, let's say debug and it shows me that the shortcut would be F5
For offline use there's the posters with key bindings, but inside VS I'd recommend the IntelliCommand extension which will show you key combinations when you press ctrl (+ some other key).
No other addin/tool required. In Visual Studio, under Tools > Options > Environment > Keyboard, you can find all available shortcuts.

Visual Studio Productivity Power Tools - Solution Navigator Shortcut

Love the Solution Navigator in VS2010 power tools. But can't find a shortcut combination that opens it?
Looking in my keyboard mappings it was down as Ctrl w+ Ctrl F. This seemed to clash with the search functionality so I reassigned it.

Visual Studio shortcut

Is there a Visual Studio shortcut to highlight the current file in Solution Explorer?
You can enable this option to always highlight the current (active) file:
Tools -> Options -> Projects and
Solutions -> Track Active Item in
Solution Explorer
To my knowledge there's no shortcut to go to it directly, however you could bind your own key combination by going to Tools -> Options -> Environment -> Keyboard, search for View.TrackActivityInSolutionExplorer then assign a shortcut to it. The downside to this approach is that it toggles the option on and off rather than perform a one time highlight of the active file.
Alternately, you can use a macro to accomplish what you originally asked about. This blog post provides such a macro: Visual Studio Macro: Locate Item in Solution Explorer on Demand.
Tools – Options – Projects and Solutions – Track Active Item in Solution Explorer
the option for auto-sync is:
Tools|Options|Projects and Solutions|General|Track Active Item in Solution Explorer
this will give an outline of the class or file you are currently working on
You can use Resharper:
Shift + Alt + L

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

Resources