44

If I open a file in Visual Studio Code from the command line or from within File Explorer, each file will open in a separate Code instance. Is there a way to make them all open in the same instance? I.e. add them all to the 'Working Files' list?

2
  • Do you mean when no other instance of VS Code was running at the time you invoke this or when an instance is already opened? Commented Sep 23, 2015 at 14:16
  • I mean when an instance is already running. Commented Sep 24, 2015 at 9:33

3 Answers 3

50

Upcoming version will have a new option files.openInNewWindow which you can set to off to always open files into the last active instance. This is then identical to starting VS Code with the -r option but is much nicer to use (e.g. when you open a file from the desktop).

Update for our VS Code 1.0 release:

The setting is available as window.openFilesInNewWindow

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

4 Comments

@DavidA, you should accept this as the correct answer.
Also, the options for this setting are "default", "on", and "off". The one you should choose to get the desired results is "off".
original comment says to set this to false but @ChaseSandmann is correct, it should be set to "off"
@Benjamin Pasero - my setting is "window.openFilesInNewWindow": "off", but still when I say "code blah" in terminal it opens in a new VSCode instance.
12

You can use the command line option of -r or --reuse-window to assure it opens in the last active VS Code window

You can review the other options here

2 Comments

that just re-uses (closes without warning the previously opened folder) - why cant it just open a file tab (or as in their terminology - "editor") within same folder ?? Of course if you give another path, opening another window is fine)
This comes by default in Mint 19 Mate but doesn't work.
3

code Folder1/File1.txt Folder2/File2.java Folder3/File3.css

This command opens three files in one instance of the editor. All files are going to be added to the working files list. This even works with much more files in the parameter list.

1 Comment

Thank you. I separated the files with commas, like some PowerShell tasks require, and failed to try obvious solution :).

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.