Remember previously open files when launching Visual Studio Code to edit a file - visual-studio-code

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

Related

Unable to open project in VS Code

I'm trying to open a project in VS Code. But I also have the same project open in IntelliJ in my laptop. Is it not possible to open a project in two different IDEs at the same time?
I am able to open other projects in vs code, but if I already have a project open intellij, I cannot open that in vs code. Is this not allowed in VS code?
Should I change anything in the settings of VS code??
Try right-clicking on the header "Explorer" in the Explorer sidebar where your open folder(s) usually appear. Two options, "Open Editors" and "Folders" will appear. Click "Folders" to make it checked and your folders will appear.

How to disable VSCode from remembering opened editors in the folder I opened before?

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

Visual Studio Code in Explorer's context menu

I want to be Visual Studio Code my default editor for all text-based file types in Windows. For Notepad++ there is an extension in the Windows Explorer to provide "Edit in Notepad++" for each file.
How can I achieve this for "Edit with Visual Studio Code"?
Do I have to "program" such extension on my own or are there any ready-to-use solutions available?
According to this blog post you can set this option during the installation process. If you want to add this option afterwards you either can follow the instructions of the rest of the post or (as recommended) reinstall vscode and then select that option during reinstalling.
When I faced the same issue, for me it was more comfortable to simply reinstall vscode.
It is east !
step 1 -->
Right click the file you want to always open with VS code
example - if you want to always open .txt files in VS code then Right click on any .txt file that is in you system
see this
step 2 -->
click on 'open with'
see this
step 3 -->
click on 'choose another app'
see this
step 4 -->
a new window will open, it will show all the applications on you system that are capable to open that file
click on VS code
and check the box at the bottom that says 'always use this app to open .txt files'
see this
and then click on open
THATS IT
NOW ON .txt FILES WILL BE OPENED IN VS CODE
.txt file extension is just an example, you can do this to any file example .py, .html, .pdf etc.

Empty Sidebar on Visual Studio Code on File -> Open

I have been using Visual Studio Code for sometime and its really amazing so far. But often I stumble upon an issue where if I import project through File->Open I end up with empty sidebar. If I do cmd+P to load files, files are available but its just not visible on sidebar.
Trying open projects with File->Open Recents or Ctrl+R also dint work out.
After reporting the issue to Visual Studio Code's github link, they have resolved the issue pretty fast.
Reason
Users who had file explorer hidden in 1.15 release might not see file explorer and also cannot retrieve it after upgrading to latest version. Workaround is to upgrade to insiders containing the fix or clear cache for that folder as follows:
Steps
Close the window opening the folder that has this issue
Open new empty Window
Run command Developer: Toggle Developer Tools
Go to Application Tab in Developer tools
Select file:// under Local Storage section in the menu on the left
Search for the key workbench.explorer.views.state using Filter inputbox
Select the folder with this key and Delete it
Now open the folder in VS Code and you should be seeing the file explorer.

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)