I have already remapped ctl+tab and ctl+shift+tab to Window.NextTab and Window.PreviousTab.
But when I call File.Close, Visual Studio 2013 still uses MRU to decide which tab to bring to the foreground, which usually results in focus jumping somewhere unepxected. I would like to change this behavior so that the tab right after the just-closed one (to the right in the tab well) is brought to the foreground (if it exists). This would make VS's behavior match that of ff, chrome, notepad++ etc.
I've tried a bunch of extensions, and while many of them change or create their own next / previous tab functions, none seems to make a new version of File.Close.
Does anyone know if this is possible or the identity of any extensions which do it?
You can use the following command created in Visual Commander instead of File.Close to activate next tab after close:
public class C : VisualCommanderExt.ICommand
{
public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
{
dte = DTE;
if (IsCommandAvailable("Window.NextTab"))
{
DTE.ExecuteCommand("Window.NextTab");
DTE.ExecuteCommand("Window.PreviousTab");
}
if (IsCommandAvailable("File.Close"))
DTE.ExecuteCommand("File.Close");
}
private bool IsCommandAvailable(string commandName)
{
EnvDTE80.Commands2 commands = dte.Commands as EnvDTE80.Commands2;
if (commands == null)
return false;
EnvDTE.Command command = commands.Item(commandName, 0);
if (command == null)
return false;
return command.IsAvailable;
}
private EnvDTE80.DTE2 dte;
}
Update A probably better implementation that prevents potential visual side effects:
public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
{
dte = DTE;
if (IsCommandAvailable("Window.NextTab"))
{
EnvDTE.Window w = DTE.ActiveWindow;
DTE.ExecuteCommand("Window.NextTab");
w.Close();
}
else if (IsCommandAvailable("File.Close"))
DTE.ExecuteCommand("File.Close");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With