1

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.

4
  • Your question is not very clear, but if you mean editing variables easily, then see this answer. 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). Commented Jun 26, 2023 at 11:25
  • 1
    I see, I think this will help you VScode run code selection, VS Code execute current line or selection to in the integrated console Commented Jun 26, 2023 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. Commented Jun 26, 2023 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? Commented Jun 26, 2023 at 17:43

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

could you tell me how to do that please?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.