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

前端 未结 13 587
半阙折子戏
半阙折子戏 2020-11-28 17:39

Is it possible to change how Ctrl + Tab and Shift + Ctrl + Tab work in Visual Studio? I have disabled the popup naviga

13条回答
  •  醉话见心
    2020-11-28 18:10

    After a couple of hours of searching I found a solution how to switch between open documents using CTRL+TAB which move from left to right and SHIFT+ CTRL+ TAB to go right to left.

    In short you need to copy and paste this macro:

    Imports System
    Imports EnvDTE
    Imports EnvDTE80
    Imports EnvDTE90
    Imports System.Diagnostics
    
    Public Module TabCtrl
    
    Public Sub TabForward()
        Dim i As Integer
        Dim activateNext As Boolean = False
    
        For i = 1 To DTE.Windows.Count
            If DTE.Windows().Item(i).Kind = "Document" Then
    
                If activateNext Then
                    DTE.Windows().Item(i).Activate()
                    GoTo done
                End If
    
                If DTE.Windows().Item(i) Is DTE.ActiveWindow Then
                    activateNext = True
                End If
            End If
        Next
    
        ' Was the last window... go back to the first
        If activateNext Then
            For i = 1 To DTE.Windows.Count
                If DTE.Windows().Item(i).Kind = "Document" Then
                    DTE.Windows().Item(i).Activate()
                    GoTo done
                End If
            Next
        End If
    done:
    
    End Sub
    
    Public Sub TabBackward()
        Dim i As Integer
        Dim activateNext As Boolean = False
    
        For i = DTE.Windows.Count To 1 Step -1
            If DTE.Windows().Item(i).Kind = "Document" Then
    
                If activateNext Then
                    DTE.Windows().Item(i).Activate()
                    GoTo done
                End If
    
                If DTE.Windows().Item(i) Is DTE.ActiveWindow Then
                    activateNext = True
                End If
            End If
        Next
    
        ' Was the first window... go back to the last
        If activateNext Then
            For i = DTE.Windows.Count To 1 Step -1
                If DTE.Windows().Item(i).Kind = "Document" Then
                    DTE.Windows().Item(i).Activate()
                    GoTo done
                End If
            Next
        End If
    done:
    
    End Sub
    
    End Module
    

    The macro comes from: www.mrspeaker.net/2006/10/12/tab-un-stupidifier/

    If you never add a macro to Visual Studio there is a very useful link how to do it.

提交回复
热议问题