0

How can I run a single line in debug console in VS Code? It often happens that during debugging I want to run single lines to override variables. That can be done smoothly with spyder (which I'm migrating from), but I can't find a way to do it quickly in VS Code. The only way seems doing copy and paste every time in the debug console, but I'm looking for a quicker way.

I'm using Python and there's no screenshot to attach. I'm simply asking whether there's a quick way to run specific lines during debugging. In spyder this can be achieved pretty easily by the Run selection or current line command. I'm looking for the equivalent in Visual Studio Code.

starball
  • 20,030
  • 7
  • 43
  • 238
James Arten
  • 523
  • 5
  • 16
  • Your question is not very clear, but if you mean editing variables easily, then see [this answer](https://stackoverflow.com/questions/20398377/how-to-watch-all-variables-when-debugging-in-visual-studio-2012). this is for watch, but you edit variable's value too using methods specified in the answer. Also you didn't specify VS version, but generally this applies to all VS versions (not VS-Code). – subdeveloper Jun 26 '23 at 11:25
  • 1
    I see, I think this will help you [VScode run code selection](https://stackoverflow.com/questions/49771589/vscode-run-code-selection), [VS Code execute current line or selection to in the integrated console](https://stackoverflow.com/questions/45667252/vs-code-execute-current-line-or-selection-to-in-the-integrated-console) – subdeveloper Jun 26 '23 at 15:33
  • @subdeveloper no I don't think that helps. This question is about running code _during debugging_ and within the debug session's program's environment. read carefully please. – starball Jun 26 '23 at 17:14
  • are you debugging a single file with the button at the top-right of the screen? or are you debugging with a [launch config](https://code.visualstudio.com/docs/python/debugging)? – starball Jun 26 '23 at 17:43

1 Answers1

1

Try to put "console": "internalConsole" in your launch.json. That will make it use the integrated console, where I think you can get what you are looking for. I don't know about running selections of code, but I just tried, and I could write things for the Python interpreter to execute when paused at breakpoints in the integrated console's input box.

starball
  • 20,030
  • 7
  • 43
  • 238