Home
%3CLINGO-SUB%20id%3D%22lingo-sub-853822%22%20slang%3D%22en-US%22%3EOpen%20folders%20on%20Current%20Visual%20Studio%20Code%20Window%20from%20terminal%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-853822%22%20slang%3D%22en-US%22%3E%3CP%3EI%20usually%20used%20%60code%20.%60%20command%20to%20open%20a%20folder%20using%20Visual%20Studio%20Code%2C%20however%20it%20open%20as%20new%20Window.%3C%2FP%3E%0A%3CP%3ESo%2C%20I%20used%20folder%20open%20dialog%20to%20open%20a%20folder%20by%20current%20Window.%20GUI%20is%20useful.%20But%20I%20sometime%20had%20felt%20that%20I%20don't%20want%20to%20leave%20terminal%20window.%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1821070789%22%20id%3D%22toc-hId-1821070789%22%20id%3D%22toc-hId-1821070789%22%3EThe%20solution!!%3C%2FH2%3E%0A%3CP%3EI%20checked%20a%20following%20document.%20I%20found%20-r%20option%20and%20--add%20option!!%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcode.visualstudio.com%2Fdocs%2Feditor%2Fcommand-line%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fcode.visualstudio.com%2Fdocs%2Feditor%2Fcommand-line%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E-r%20option%20is%20to%20open%20a%20folder%20by%20current%20window%2C%20--add%20option%20is%20to%20add%20a%20folder%20to%20current%20work%20space.%3C%2FP%3E%0A%3CP%3EIf%20I%20would%20like%20to%20add%20two%20folders%20to%20Visual%20Studio%20Code%2C%20the%20folder%20names%20are%20'sample1'%20and%20'sample2'%2C%20and%20initialize%20as%20git%20repositories.%3C%2FP%3E%0A%3CP%3EI%20just%20type%20following%20command%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%24%20mkdir%20sample1%0A%24%20cd%20sample1%0A%24%20git%20init%0A%24%20code%20-r%20.%0A%24%20cd%20..%0A%24%20mkdir%20sample2%0A%24%20cd%20sample2%0A%24%20git%20init%0A%24%20code%20--add%20.%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F131620i91D0FFA463B90EA6%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22vscode.gif%22%20title%3D%22vscode.gif%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EWhat's%20a%20useful%20feature!!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-854187%22%20slang%3D%22en-US%22%3ERe%3A%20Open%20folders%20on%20Current%20Visual%20Studio%20Code%20Window%20from%20terminal%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-854187%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20for%20the%20Tip%20KazukiOta%26nbsp%3B%3CIMG%20class%3D%22lia-deferred-image%20lia-image-emoji%22%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Fhtml%2Fimages%2Femoticons%2Fcool_40x40.gif%22%20alt%3D%22%3Acool%3A%22%20title%3D%22%3Acool%3A%22%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

I usually used `code .` command to open a folder using Visual Studio Code, however it open as new Window.

So, I used folder open dialog to open a folder by current Window. GUI is useful. But I sometime had felt that I don't want to leave terminal window.

The solution!!

I checked a following document. I found -r option and --add option!!

https://code.visualstudio.com/docs/editor/command-line

 

-r option is to open a folder by current window, --add option is to add a folder to current work space.

If I would like to add two folders to Visual Studio Code, the folder names are 'sample1' and 'sample2', and initialize as git repositories.

I just type following command:

 

 

$ mkdir sample1
$ cd sample1
$ git init
$ code -r .
$ cd ..
$ mkdir sample2
$ cd sample2
$ git init
$ code --add .

 

 

vscode.gif

What's a useful feature!!

1 Comment

Thanks for the Tip KazukiOta :cool: