2

I would like that the cursor stays in the script file after I run a code selection with F8. What setting should I change so the cursor does not move to the terminal?

mklement0
  • 382,024
  • 64
  • 607
  • 775
xhr489
  • 1,957
  • 13
  • 39

1 Answers1

3

Assuming that the PowerShell extension for Visual Studio Code or Azure Data Studio (ADS) is installed, add the following line to your settings.json file (before the closing }):

  "powershell.integratedConsole.focusConsoleOnExecute": false, 

Alternatively, use the settings GUI (press Ctrl+,):

Settings GUI with relevant setting shown

Note the GUI's convenient search feature: typing powershell focus was sufficient to locate the relevant setting.

mklement0
  • 382,024
  • 64
  • 607
  • 775
  • Hi is this also possible in PowerShell ISE? – xhr489 Mar 12 '22 at 18:30
  • 1
    @xhr489, there's no standard option, but my guess is that you could author an add-on to do it. However, I suggest moving away from the ISE, because it is [no longer actively developed](https://learn.microsoft.com/en-us/powershell/scripting/components/ise/introducing-the-windows-powershell-ise#support) and [there are reasons not to use it](https://stackoverflow.com/a/57134096/45375) (bottom section), notably not being able to run PowerShell (Core) 6+ – mklement0 Mar 12 '22 at 18:43
  • Where is the stop buttom in Visual Studio, like the one in ISE? – xhr489 Mar 12 '22 at 20:15
  • 1
    @xhr489, in VS Code, while a script is running in the debugger, a floating toolbar is being displayed that has a Stop button, but please consider creating new question posts if you need additional assistance. – mklement0 Mar 12 '22 at 20:18