skip to Main Content

VS Code Version: 1.87.2
OS Version: Windows 10 22H2 19045.4046

I’m having a weird issue trying to open my files from terminal in VSCode on windows. As far as I know using -r should force opening a file in the same instance of VSCode, but no matter how my settings is setup I still get a new instance opening up every time!

Already googled solutions and searched through stackoverflow, tried both "window.openFilesInNewWindow": "off"
"window.openWithoutArgumentsInNewWindow": "off"
Doesn’t seem to have any effects on my issue. Am I missing something?

note: working on a Django project repo if it helps.

Steps to Reproduce:

  • Open a new terminal (PowerShell) in your workspace.
  • cd to your desired directory
  • Run code -r yourfile.py
  • A new instance of VSCode will pop up opening yourfile.py instead of yourfile.py opening in the same VSCode instance

Any suggestions would be much appreciated

  • Edit 1: Think it could potentially be a bug of some sorts, either at my end or globally. Made a ticket on VSCode github to see. will update if I get more info or guidance on this.

  • Edit 2: For some weird reason, if I run the executable from the command line, it would grab code -r filename.ext just fine. But if I open the executable using windows explorer it somehow gives me some sort of local instance that terminal doesn’t grab, even though both executables are running under the same username and privileges. Can’t figure out why and how, but at least I’ve got a decent workaround for the moment thanks to
    Tripp Kinetics comments 🙂

2

Answers


  1. I do not understand exactly what you want to do.
    Here are some of my suggestions:

    Running python code in the vsc terminal?

    python your_file.py

    Running a pip command?

    python -m pip install -r requirements.txt

    The terminal does not have a -r flag. This is also true for Python.

    Login or Signup to reply.
  2. If you start the initial VS Code window using the Terminal window, then subsequent calls to the code.exe executable from the same window will open the new file in the same window. So, just make sure to start your session from the Windows Terminal instead of from Windows Explorer, and Bob’s your uncle.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search