Vscode will not autofocus on integrated terminal while running code

Question:

When I run without debugging in python on vscode it no longer autofocuses on the terminal forcing me to click into the terminal everytime to input data. Is there any solution to cause vscode to autofocus when code is running?

Asked By: Incisor

||

Answers:

I think there is no relevant implementation method for code runner at present. You could use shortcut "Ctrl+~" to foucus on the terminal, and I will submit the function to GitHub.

Answered By: MingJie-MSFT

Two Fixes/Workarounds I utilized.

Autohotkey Script:

F9::
Send {F5}
Sleep 200
SendInput ^{~}

Or Rebind:

View: Toggle Terminal Originally (Ctrl + ~) to F5 so jumps to the terminal everytime you run

Answered By: Incisor

The following solution to this issue has been tested on Visual Studio Code 1.74.3.

  1. Install the Python extension for Visual Studio Code.
  2. Go to File >> Preferences >> Settings.
  3. In the Search settings field enter, "Python › Terminal: Focus After Launch"
  4. Click on, When launching a python terminal, whether to focus the cursor on the terminal.
  5. A check mark should appear in the tick box.

Done! Now every time you Run Python File the terminal will be focused.

Answered By: q-l-p
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.