Changing Ctrl + Tab behavior for moving between documents in Visual Studio

Viewed 84300

Is it possible to change how Ctrl + Tab and Shift + Ctrl + Tab work in Visual Studio? I have disabled the popup navigator window, because I only want to switch between items in the tab control. My problem is the inconsistency of what switching to the next and previous document do.

Every other program that uses a tab control for open document I have seen uses Ctrl + Tab to move from left to right and Shift + Ctrl + Tab to go right to left. Visual Studio breaks this with its jump to the last tab selected. You can never know what document you will end up on, and it is never the same way twice.

It is very counterintuitive. Is this a subtle way to encourage everyone to only ever have two document open at once?


Let's say I have a few files open. I am working in one, and I need to see what is in the next tab to the right. In every other single application on the face of the Earth, Ctrl + Tab will get me there. But in Visual Studio, I have no idea which of the other tabs it will take me to. If I only ever have two documents open, this works great. As soon as you go to three or more, all bets are off as to what tab Visual Studio has decided to send you to.

The problem with this is that I shouldn't have to think about the tool, it should fade into the background, and I should be thinking about the task. The current tab behavior keeps pulling me out of the task and makes me have to pay attention to the tool.

14 Answers

The philosophy of the Visual Studio tab order is very counterintuitive since the order of the displayed tabs differs from the tab-switching logic, rendering the ordering of the tabs completely useless.

So until a better solution arises, change the window layout (in Environment->General) from tabbed-documents to multiple-documents; it will not change the behaviour, but it reduces the confusion caused by the tabs.

That way you will also find the DocumentWindowNav more useful!

I guess you want what VSS calls Next(Previous)DocumentWindow. By default, it's on Ctrl(-Shift)-F6 on my VSS 8. On Ctrl(-Shift)-Tab they have Next(Previous)DocumentWindowNav. You can change key assignments via Tools/Options/Keyboard.

I'm 100% in agreement with Jeff.

I had worked on Borland C++ Builder for several years and one of the features I miss most is the 'correct' document tabbing order with Ctrl-Tab. As Jeff said, "The current tab behavior keeps pulling me out of the task and makes me have to pay attention to the tool " is exactly how I feels about this, and I'm very much surprised by the fact that there aren't many people complaining about this.

I think Ctrl-F6 - NextDocumentWindowNav - navigates documents based on the document's last-activated time. This behavior is a lot like how MDI applications used to behave in old days.

With this taken this into account, I usually use Ctrl+F6 to switch between 2 documents (which is pretty handy in switching between .cpp and .h files when working on c++ project) even when there are more than 2 currently opened documents. For example, if you have 10 documents open (Tab1, Tab2, Tab3, ...., Tab10), I click on Tab1 and then Tab2. When I do Ctrl+F6 and release keys, I'll jump to Tab1. Pressing Ctrl+F6 again will take me back to Tab2.

Updated to VS 2017+, where, according to @J-Bob's comment under @thepaulpage's answer, (emphasis added):

Looks like the commands have changed again. It's now 2017 and the keyboard shortcuts are called Open Next Editor and Open Previous Editor. You don't need any extensions for this.

You can find the options under Settings, which can be accessed via the gear symbol in the lower left, or by the [Ctrl]+, command.

I feel the top answer at the moment is outdated. In Visual Studio 2021 (v1.56), you do not need to install any extensions or mess around with any configuration files. You simply need to do the following steps:

  1. Click the gear icon in the bottom-left.
  2. Select 'Keyboard Shortcuts'.
  3. Search for 'workbench.action.previousEditor' and 'workbench.action.nextEditor' and edit their keybindings by clicking the pencil icon on the left side of the row.

If you do change to 'Ctrl+tab' or any other shortcut that is already in use by another command, it will let you know and give you the option to change those. I personally changed them to 'Ctrl+PgUp' and 'Ctrl+PgDn' so it was just a straight swap.

I don't use Visual Studio (yes, really, I don't use it), but AutoHotkey can remap any hotkey globally or in a particular application:

#IfWinActive Microsoft Excel (application specific remapping)

; Printing area in Excel (@ Ctrl+Alt+A)
^!a::
Send !ade
return

#IfWinActive


$f4::
; Closes the active window (make double tapping F4 works like ALT+F4)
if f4_cnt > 0 
{
    f4_cnt += 1
    return
}

f4_cnt = 1
SetTimer, f4_Handler, 250
return

f4_Handler:
SetTimer, f4_Handler, off

if (f4_cnt >= 2)    ; Pressed more than two times
{   
    SendInput !{f4}
} else {
    ; Resend f4 to the application
    Send {f4}
}

f4_cnt = 0
return

These are two remappings of my main AutoHotKey script. I think it's an excellent tool for this type of tasks.

Related