Vscode: Open VS Code file / folder from command line in the same window in a new tab in macOS

Created on 2 Nov 2016  路  2Comments  路  Source: microsoft/vscode

  • VSCode Version: 1.6.1
  • OS Version: macOS 10.11.6

I can open Visual Studio Code from cli by using open -a Visual\ Studio\ Code + file/folder name.

This however always opens the file/folder in a new window. Since I like to run VS Code in full screen, this is very annoying for me. Is it possible to make a cli that will open files in the same VS Code window in a new tab?

Thank you.

*question

Most helpful comment

You don't have to use open -a, there is a proper CLI tool included.

Setup instructions can be found here: https://code.visualstudio.com/docs/setup/mac right at the top.

If you want to open a folder, just use code . from any terminal. Files are opened in a new window by default, but you can reuse your existing window / open project with code -r myFileToOpen.txt.

All 2 comments

You don't have to use open -a, there is a proper CLI tool included.

Setup instructions can be found here: https://code.visualstudio.com/docs/setup/mac right at the top.

If you want to open a folder, just use code . from any terminal. Files are opened in a new window by default, but you can reuse your existing window / open project with code -r myFileToOpen.txt.

@kaiwood already explained perfectly how to handle this.

Was this page helpful?
0 / 5 - 0 ratings