In VS Code, how do I jump to the current position of the debugger? It is indicated by a yellowish line, but I tend to get lost browsing other files and functions, only to struggle finding my way back to where my debugging session is currently paused at.
Should be simple enough, but I could not find anything in the docs. I even went through all actions containing 'debug' in the keyboard map, but did not find what I'm looking for.
You can define a keyboard shortcut for any task. From the Command Palette (Ctrl+Shift+P), select Preferences: Open Keyboard Shortcuts File, bind the desired shortcut to the workbench.
The desired effect (jump to the current execution point) can be achieved by clicking on (or selecting with the keyboard) the topmost entry in the "Call Stack" view.
Using the multi-command macro extension (inspired by Mark's answer), a custom command can be created which will always select the topmost entry in the call stack view.
This goes to your keybindings.json
:
{
"key": "cmd+f4",
// Go to current debugging position
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
"workbench.debug.action.focusCallStackView",
"list.clear",
"list.focusFirst",
"list.select"
// optional, to focus your editor:
// workbench.files.action.focusOpenEditorsView
]
}
},
There doesn't appear to be any go to current breakpoint
command, only previous and next commands.
However, I see this "bug" might be useful: see repl evaluation causes editor to jump to current breakpoint!
So you could just focus the repl, Enter and you will jump to your current breakpoint. It does pollute your debug console with an undefined
result but perhaps that is acceptable.
Or you could assign a keybinding to a macro that executes the focus command and clears the debug console in one go. Using a macro extension of your choice - I am using multi-command below - this would go into your settings:
"multiCommand.commands": [
{
"command": "multiCommand.gotoCurrentBreakpoint",
// "interval": 350,
"sequence": [
"workbench.debug.action.focusRepl",
"repl.action.acceptInput",
// following command clears the debug console if you wish
"workbench.debug.panel.action.clearReplAction"
]
}
]
and some keybinding:
{
"key": "alt+/",
"command": "extension.multiCommand.execute",
"args": { "command": "multiCommand.gotoCurrentBreakpoint" },
},
How long the underlying "bug" - if it is a bug - will be there to use .....?
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