How to disable VSCode from remembering opened editors in the folder I opened before? - visual-studio-code

After I use VSCode to open a folder and some editors for the files, I close the folder. When I close and reopen the folder, VSCode opens the editors I opened last time.
How to prevent VSCode from reopening the editors I opened last time?
I have already set "window.restoreWindows": "none". When I exit directly from VSCode, it won't restore windows. I am saying when I reopen a folder, the editors I opened last time before I close the folder, will still be opened.

To stop Visual Studio Code from opening your previous folder all the time, then you have to edit settings.json.
To achieve this, open the settings.json. Do this by following the steps below.
Open the Command Palette by pressing F1.
Type, "Open settings".
When you see the options, select Open Settings (JSON).
After that, add the following option.
{
"window.restoreWindows": "none"
}
This should prevent Visual Studio Code from opening the previous folder when launching the application.

I just open vscode from my terminal, it's way faster and efficient in my opinion.
Just browse to your wished folder and write "code ." in your terminal.

Follow this process
Open VS Code, goto file>preferences>settings.
search for restore Window or click on Window tab then find restore window .select none from selection.
https://i.stack.imgur.com/FLx4a.png
https://i.stack.imgur.com/TAuHT.png
https://i.stack.imgur.com/B8W5a.png

Related

Is there any Windows 10 keyboard shortcut to open a folder from the file explorer with VS Code instead of Right clicking and 'open with code' [duplicate]

I don't see a keyboard shortcut for "Open Folder..." listed on the documentation page below, and after searching elsewhere for a while I didn't see anything else.
https://code.visualstudio.com/docs/customization/keybindings
I thought I would ask here before putting an issue on GitHub about it. (Also there doesn't seem to be a open / closed issue about this anywhere on the GitHub repo.)
https://github.com/Microsoft/vscode/issues
There is indeed a shortcut for it, the command is workbench.action.files.openFolder, and the default keybinding is Ctrl+K,Ctrl+O.
It's easy to find in the list of shortcuts (File → Preferences → Keyboard Shortcuts) if you search for "folder" or "openFolder" in the Default Keybindings.
Hit Cmd+O on macOS or Ctrl+O on Windows/Linux to activate the open dialog, select a folder, and click "Open."
Note: This answer was written before multiple folder workspaces were implemented in VS Code. If you open folders this way, it will replace your entire workspace with the folder you selected to open. If you want to add a folder to your existing workspace, you must use Cmd+K, Cmd+O on a macOS or Ctrl+K, Ctrl+O on Windows/Linux.

Remember previously open files when launching Visual Studio Code to edit a file

If I launch Visual Studio Code directly it remembers all the files I had open previously. The issue I have is if I (under Win10) right click a file and select "Open With Code". If VS Code is already open everything is file. If VS Code is not open, it will launch and open the file, but forget all the files I had previously opened.
This seems like unexpected (and non-consistent) behavior. Is there a way to get VS Code to launch from "Open With Code" but have it also open all the files I had opened previously? Basically, act the same as if VS Code was already opened when I clicked on "Open With Code".
Add the following line to your setting.json (Code Menu > Preferences > Setting)
"window.restoreWindows": preserve
This issue seems to cover exactly your case and has been resolved here

VSCode Switch Off Editor History

How to make VSCode to use only current project files when using dialog for quick file open by name or we always have to clean editor history so recent files won't be showing there?
This setting:
Search > Quick Open: Include History
Whether to include results from recently opened files in the file
results for Quick Open.
Uncheck it to set it to false.

How to reopen last opened file in vscode

If i close the vscode editor after saving a file and reopen the editor again, the session is not restored. I am unable to find the file in open recent. The only way how can I open the file is navigating to the directory in open menu. Thats very annoying is it some problem with my editor or default behaviour?
You must have a folder opened to restore previously opened files.
Go to 'File' menu
Open folder
Select a folder (my documents for example)
Now open any files, close vscode and re-open. Your files are still in the editor.
"window.restoreWindows": "all" will do ;)
The complete settings are
"window.restoreWindows": "all",
"files.hotExit":"onExitAndWindowClose",
Note that with:
VSCode 1.42 (Jan. 2020) it does work even in case of "hot exit" (unexpected exits): see "Visual Studio Code never reopens previous file or folder".
VSCode 1.51 (Oct. 2020), that will also restore a search tab if you had one (issue 102659 resolved by issue 99694, and commit 8bf0e20)

User Setting for default save and open locations in VS Code

Is there a property name that can be added to the settings.json for the default open/save location?
There is not. The workaround would be to create a shortcut to launch vscode with the location of the folder you want to open on startup. You can append a path as argument for VS Code to open.
In addition, VS Code will always remember the last folder you opened and restore it when you restart.
I found a solution. Edit the shortcut of VSCode and change the startup location.
On Windows:
Open Start Menu and locate Visual Studio Code
Right click on the Visual Studio Code icon
Select More >
Select Open File Location
Right click on the shortcut icon and select Property
Change the Startup Location to what you want
Save files to a default location in local machine with VS Code on Mac:
Here is a screenshot of how to get into VS preferences. Click VS community (on your menu bar) and the drop-down menu will display preferences. Within preferences, click on projects then load/save and you will find the default load/save locations.