Search code examples
visual-studio-code

How to open folders in VSCode via Terminal in a fresh state?


It appears that VSCode always opens a folder in with the last UI state it had.

I'm looking for something like Sublime's remember_open_files: false, or in other words, I would like VSCode to open up with a clean UI state regardless of what state the UI was in the last time the folder was open.

What's happening now:

cd my-project-folder/
code .
# VSCode opens folder with saved UI state

What I want:

cd my-project-folder/
code .
# VSCode opens folder with fresh UI state

Solution

  • I tried to do it through command line using the command

    code -n .
    

    which should have opened VS code in current folder with a new session but it does not seem to work at all. I believe that code . seems to ignore the -n new session option and restores the previous session for the folder. So this feature is probably not implemented in VS code.

    (Refer here for the commandline options for VS code.)