views:

725

answers:

3

Visual Studio gives many navigation hotkeys: F8 for next item in current panel (search results, errors ...), Control+K,N for bookmarks, Alt- for going back and more.

There is one hotkey that I can't find, and I can't even find the menu-command for it, so I can't create the hotkey myself.

I don't know if such exist:

Previous and Next call-stack frame. I try not using the mouse when programming, but when I need to go back the stack, I must use it to double click the previous frame.

Anyone? How about a macro that does it?

Thanks.

A: 

Look in Tools->Options->Environment->Keyboard. Enter "stack" or "frame" and related menus will appear. It seems that there's no next and previous call-stack frame.

John
Thanks for the fast reply!But that's exactly what I've said: "...can't even find the menu-command for it."
@Adrian Aisemberg, I think he is answering your question. I think he's saying that there is no such shortcut key.
Onorio Catenacci
So how about creating one with a macro?
A: 

I don't think theres an explict next-frame / prev-frame key binding but heres what I do.

CTRL-ALT-C is already bound to "Debug.CallStack" This will focus you in the Call Stack Tool Window

Once focused in the Callstack window... Up & Down arrows will move you through the call stack frames

I've then bound

CTRL-C, CTRL-S to "DebuggerContextMenus.CallStackWindow.SwitchToFrame" and CTRL-C, CTRL-C to "DebuggerContextMenus.CallStackWindow.SwitchToCode"

both of which will take you back into the code window at the particular frame.

Hope that helps.

Eoin Campbell
+2  A: 

I've wrote 2 macros for these purposes: PreviousStackFrame and NextStackFrame and assigned shortcuts to

Function StackFrameIndex(ByRef aFrames As EnvDTE.StackFrames, ByRef aFrame As EnvDTE.StackFrame) As Long
    For StackFrameIndex = 1 To aFrames.Count
        If aFrames.Item(StackFrameIndex) Is aFrame Then Exit Function
    Next
    StackFrameIndex = -1
End Function

Sub NavigateStack(ByVal aShift As Long)
    If DTE.Debugger.CurrentProgram Is Nothing Then
        DTE.StatusBar.Text = "No program is currently being debugged."
        Exit Sub
    End If

    Dim ind As Long = StackFrameIndex(DTE.Debugger.CurrentThread.StackFrames, DTE.Debugger.CurrentStackFrame)
    If ind = -1 Then
        DTE.StatusBar.Text = "Stack navigation failed"
        Exit Sub
    End If

    ind = ind + aShift
    If ind <= 0 Or ind > DTE.Debugger.CurrentThread.StackFrames.Count Then
        DTE.StatusBar.Text = "Stack frame index is out of range"
        Exit Sub
    End If

    DTE.Debugger.CurrentStackFrame = DTE.Debugger.CurrentThread.StackFrames.Item(ind)
    DTE.StatusBar.Text = "Stack frame index: " & ind & " of " & DTE.Debugger.CurrentThread.StackFrames.Count
End Sub

Sub PreviousStackFrame()
    NavigateStack(1)
End Sub

Sub NextStackFrame()
    NavigateStack(-1)
End Sub
Oleg Svechkarenko
This macro works great! Thanks a lot :D
Antoine Aubry