I'm new to Visual Studio Code. I've been tinkering with the settings for a while now and haven't yet found a way to make VSCode automatically reopen last closed tab(s). Say, I opened file 1, closed VSCode, went to open file 2 (in a separate folder), just to end up with only one tab opened despite what I have in my settings.json file:
"files.hotExit": "onExit",
"window.reopenFolders": "all",
"window.restoreWindows": "all"
I don't mind accumulated tabs every time I open VSCode, (Ctrl+w exists for a reason); if Notepad++ and Sublime Text can do it, then why not VSCode? Or am I missing something?
VS Code can currently only open one workspace in one window. Unless you have manually specified a multi-root workspace, VS Code will always open new files and folders as separate workspaces.
Related
There are some guides in stackoverflow for opening multiple windows in Visual Studio. But it is inside the Visual Studio they are talking about.
Here is what I want. There is one txt file called A.txt in my desktop, I right click it and the context option shows Open With Code, and I open it. There is another txt file called B.txt in my desktop. While I right clit it and open it with visual studio code, both the two files are in the same window.
Is there any setting that the two files can be opened in two windows?
Not sure why you want that but actually there is a setting which behaves like you want when turned to "On":
Window: Open Files In New Window Controls whether files should open in
a new window when using a command line or file dialog. Note that there
can still be cases where this setting is ignored (e.g. when using the
--new-window or --reuse-window command line option).
You can find it via: User -> Window -> New Window
You can quickly open the settings dialog by pressing CTRL + ,
Context: I have a todo list file I always want to open as a pinned file in VSCode, but it's a pain having to reopen it manually for each project.
Is there any way to force VSCode to always open a particular file any time I open a new VSCode window?
Edit:
this should ideally work for all folders, as I often access remote folders over SSH that will not have workspaces created for them
Using Visual Studio Code (latest version as well as prior versions), when using the command line to launch I am seeing some odd behavior. Trying to determine if I am missing something, or if this is a bug.
Here is the scenario.
Action 1: I have a workspace open with a couple of files open for editing. If I close VSCODE, and then just open it again the state is restored, I am in the workspace and the files are open for editing. Great.
Action 2: I have a workspace open with a couple of files open for editing. If I then from a command line do "vscode testfile.txt" then the new file gets opened in VSCODE and joins the other opened file. Great.
Action 3: I have a workspace open with a couple of files open for editing. I close VSCODE. I then from a command line do "vscode testfile.txt". VSCODE starts up, but only the new file gets opened in VSCODE. The workspace I had opened is not any more, and the files I had opened are no longer opened. Not so great.
I have tried adding the -r option on the command line but that didn't change anything.
This feels like a bug, but if not help me understand how I get the desired result, which is when VSCODE is not running, and I try to edit a file from the command line, I want VSCODE to restore to the state it was in when last closed, and then add that new file to the mix. Just like if it was already running.
I'm trying to set up VS Code such that when the program is just opened (not via the context menu for a file or clicking on a file) a new blank text file is open and ready to start typing in - similar to when Notepad++ is opened - or most other text editors, for that matter.
Searching for "VS Code open with new file" and many variants only brings me to articles/posts about opening a new file in a new tab or window. That's not what I'm trying to do.
File > Preferences > Settings
Search for startupEditor
Change
"workbench.startupEditor": "welcomePage"
to
"workbench.startupEditor": "newUntitledFile"
or select newUntitledFile from dropdown
In File > Preferences > Settings there is the following option listed under the Window section:
// Controls how windows are being reopened after a restart. Select 'none' to always start with an empty workspace, 'one' to reopen the last window you worked on, 'folders' to reopen all windows that had folders opened or 'all' to reopen all windows of your last session.
"window.restoreWindows": "none",
Using the editor in the right pane you can add:
"window.restoreWindows": "none"
Which will open an empty workspace with a link that says "new file". It's not exactly the solution you're looking for but it's the closest one I'm aware of.
This also stopped working for me. But I created a shortcut on my Taskbar like the following, and it does what I was looking for:
"C:\Users\myname\AppData\Local\Programs\Microsoft VS Code\Code.exe" C:\Users\myname\Downloads\Untitled
I gave a chance to Visual Studio Code as my primary editor. I had been using Notepad++ and afterwards I have been using Sublime Text 2 and 3 for few years. I do see potential of this editor and I really like it, but there is one thing I am strongly used to.
Notepad++ and Sublime Text has this feature, I can edit file and DON'T save it anywhere. After restart Notepad/Sublime Text this file is there ready for me.
Other workflow could be open any file from my local storage, close VS Code and start it again. This file will not open!
I know about that when I open folder and restart VS Code, folder is open and files as well. But is there any way how can I manage to have opened files after restart without having opened folder?
Edit: This is now implemented:
// Controls whether unsaved files are remembered between sessions, allowing the save prompt when exiting the editor to be skipped.
"files.hotExit": "onExit"
I use the insider release, and in the current version (1.3.0), vscode doesn't keep unsaved file. I think there is a feature request for that.
Got it: https://visualstudio.uservoice.com/forums/293070-visual-studio-code/suggestions/8568343-keep-unsaved-files-after-crash
You can vote for that feature, like I did !
On the other hand, You can tell in settings if you want to re-open previously opened folders, but not files.
"window.reopenFolders": "all"