'Issue in Visual Studio Code editor. Why are files closing when I save them?
Why are files closing when I save them?
When ever I create a new file, add a couple lines of code to the file, and attempt to save my work, the file immediately closes, right when I initiate the save. Furthermore, the file that closes is not appearing in the "Open recent" file list that's located in the file menu.
Edit : The file immediately closes after I save as it, because when I click "run Python File", It open File Explorer tab
Does anyone know if this is a known issue, or if I can solve this problem by reconfiguring a 'VS Code' setting?
Solution 1:[1]
Use Directories to Save Files
It is better to open directories in VS Code, than it is to open a single file without a parent directory.
File > Open Folder or Ctrl+K Ctrl+O
The folder that opens, using the keybinding above, can be used to save all the files you want.
Using the Open Recent File-list:
After opening Code, the last project (or folder) will already be open. If not, just go to
If not, you should be able to just go to
File > Open Recent > "Folder/Project Name"
If you use Windows, with the right button on the folder you can click on "open with code", it will open the folder directly in Code
TIP: "You can turn on auto-save — using File > Auto Save — to save time"
Solution 2:[2]
It was happening to me too. In my case it turn out to be a PHP-CS-FIXER extension has some error which was the reason the file got closed after saving. Try to disable PHP-CS-FIXER extension or may be in your case it could be some other ext
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | j D3V |
| Solution 2 | Purvesh |
