Can I somehow save window layout(with opened files) in VS Code and then restore it?
I am looking for an alternative for Emacs C-x r w <register> where I can interactively open different saved views.
Example: split the window into 3 views, open the same file in all of them scroll to different locations, save it, open other view where it's only 1 window open and then restore the 3 window view(the one I saved).
On Visual Studio Code: File -> Preferences -> Settings.
Search for Window Restore Windows -> click the dropdown and select "preserve". This will save Visual Studio Code's window layout for the next time you reopen the program.
It's very simple.
File/Preferences/Params
At right top corner click on "show params as JSON"
Add this param : window.restoreWindows": "all"
This param allow to restaure all opened file by project/folder.
If you open 2 windows with 2 differents projects, each will have files restored :)
Warning : visual studio code doesn't manage more than one windows in same on launch.
To fix that you need to create a file.bat containing this code :
code C:\path\of\one\folder && code C:\path\of\another\folder (for example)
and then create a shortcut somewhere to call this file.bat with lauchy for example :)
Related
I'm still new to VS code and I saw this type of using VS code on two monitors, so I have 3 monitors and I'm on windows 10, I use the left one as a preview for the code I'm typing in chrome so that is sorted and I want my middle one to have the main code I'm working on and my right one is set vertically so I want it to run the terminal or of that file or another file so I can use both my right and middle to write code and I have no idea how can I do this.
there is a workaround, first in the file you want to open go and click ctrl+shift+p and search for open active file in new window, then in your new instance, press again ctrl+shit+p and search for Open User Settings(JSON) and add this line at the end of the settings "files.autoSave": "onFocusChange", so whenever you change windows the current file you're working on will be auto saved, hope this helps
in VSCode is it possible to open the terminals in a separate window?
So far my research has pointed to a resounding NO but Im curious if anyone has a solution?
Move terminals between windows
It's now possible to move terminals between windows by detaching via
Terminal: Detach Session in one and attaching to another with
Terminal: Attach to Session. In the future this should help enable
cross-window drag and drop!
Lots of changes in v1.58: https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_58.md#terminals-in-the-editor-area
For v1.59 moving the terminal changes - including dragging and dropping onto another window, see https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_59.md#drag-and-drop-terminals-across-windows
Drag and drop terminals across windows
Drag terminals from the tabs
list or editor area of one window into the tabs list, editor area, or
panel of another window.
Terminals in the editor area
Terminals can now be created in or moved to the editor area, enabling a multi-dimensional grid layout that persists and remains visible regardless of panel state.
To use terminals in the editor area, there are several options:
Create via the Create Terminal in Editor Area command.
Move a terminal from the panel to the editor by dragging and dropping from the tabs list.
Running Move Terminal into Editor Area with a terminal focused.
Moving into the editor area via the terminal tab context menu action.
The new terminal.integrated.defaultLocation setting can be set to editor to direct newly created terminals to the editor area by default.
Please Try:
File > Open New Window
Ctrl+Shift+P > Terminal: Create New Terminal in Editor Area
You can add keybinding to the commands as per your convenience.
i think that the OP wants to create a separate window for the terminal but still have the separated terminal linked to the code editor in the original window (that's what i want too). so that when you run the code in the editor the output is shown in the terminal in the separate window. but if you simply open up a new window of vscode and either open a terminal there or drag and drop the terminal from the original window into the new window, the new terminal is not the same session of the terminal. it is a separate independent unconnected terminal. running the code in the editor does not show output in the new separate terminal. all you have achieved is creating a new unconnected terminal. which you could have just accomplished by opening up a regular terminal window i.e. the one from windows os main menu, no need even to use vscode.
This answer is now outdated. See this answer for instructions on moving terminal panes between VS Code windows. This answer still works but is no longer a necessary workaround.
You can't detach the panes in VSCode, which IMO is a bit of a pain since Visual Studio can detach panes all day long.
There is a workaround though, you can open a new window in VSCode and maximize the terminal pane in that window.
One reason you'd want to do this is to have the Python terminal on a second monitor while still being able to use Python interactively (shift+enter way). Attaching/detaching didn't work for me, nor can you open separate terminals.
What you can do is simply resize your one window across the screen borders! Then right click on the terminal tab/header and click Move panel to the left and voila!
Try Сtrl+Shift+c.
For me, it opens the folder the script is within in a command prompt window.
Create a new window by going to File → New Window.
Open up a new terminal inside of it.
Go to your folder (cd your\projectfolder\path).
And here you are, you have a terminal for your project inside it's own seperate window.
You can change the terminal to be side-by-side instead of below the editor. And then make your window very wide. It is almost as good as having two windows.
Right click on the TERMINAL tab.
Select "Move Views to Side Panel"
Make your window very wide
It seems VS Code allows you to detach the terminal window, but it then will not show the output from the editor of the window you detached it from.
I have spent a while searching, and there is really no workaround other than to just run whatever file you are trying to debug from a separate terminal from the same CWD. This also means you will need to save the file in the window you are editing the file in every time you want to run it. huge pain.
If you are using PowerShell inside the VSCode terminal, why don't you use the PowerShell console from the start menu. It's basically equivalent to using the terminal in separate windows. Hope it helps.Sample
I'd like to know if it is possible to open multiple files from the quick open menu in Visual Code (opened with cmd + p shortcut by default).
It would be helpful to be able to select the N first files in the results to open them at once. For instance, I could type "test_device*.js", and could open the 3 first files which are "test_device_usecase_1.js", "test_device_usecase_2.js" & "test_device_usecase_3.js", instead of having to perform more searches to open the remaining 2 files.
Thanks in advance !
You can use arrow right → to open selected file without closing quick open.
I have VS Code 1.15.1 and when I work at two projects at once, I choose File -> New Window and open the second project. Clicking File -> New Window opens new window with VS Code.
On my other computer (not sure about the VS Code version there), when I click File -> New Window, instead of opening new window, it will rather open new tab, so that I end up with two tabs in one window, each tab for one project and the active tab occupies whole screen estate.
Any ideas what should I change in Settings to achieve this "single window, multiple tabs" layout when having multiple projects?
I use macos (not sure if OS may be somehow related to the window management settings)
Go to Preferences > Settings.
Search for native tabs
Check the checkbox
Code will prompt for restart to take effect.
After restart, make sure you have multiple projects open. And then merge all windows as shown below:
Enjoy multiple tabs in single window.
Note: I think this applies to all Mac OS >= Sierra. Tested with Catalina, Big Sur recently.
Just set in your user settings
"window.nativeTabs": true
and do Window -> Merge All Windows
note: If you have High Sierra installed, that might be an issue.
Here's the link:
Better macOS native window tabs support
In Mac OS, there is a system setting outside of VS Code. Set this and then opening files/folders from the command line will also automatically open the file/folder in a new tab instead of a new window.
In MacOS 12.3 (Monterrey) this is under:
System Preferences > General > Prefer tabs ____ when opening documents.
Change this setting to always. (The default is in full
screen).
You might additionally need to set the setting in VS Code "window.nativeTabs": true as the other commenters have already suggested.
I am trying to open a tab in a new window in Visual Studio Code so I can move it to another screen. If I drag the tab the other screen, a file is created. Is there a shortcut to open a tab in a new Visual Studio Code window so I can move it to another screen?
On Windows and Linux, press CTRL+K, then release the keys and press O (the letter O, not Zero).
On macOS, press CMD+K, then O (without holding CMD).
This will open the active file tab in a new window/instance.
This is a very highly upvoted issue request in Github for Floating Windows.
Until they support it, you can try the following workarounds:
1. Duplicate Workspace in New Window [1]
The Duplicate Workspace in new Window Command was added in v1.24 (May 2018) to sort of address this.
Open up Keyboard Shortcuts Ctrl + K, Ctrl + S
Map workbench.action.duplicateWorkspaceInNewWindow to Ctrl + Shift + N or whatever you'd like
2. Open Active File in New Window [2]
Rather than manually open a new window and dragging the file, you can do it all with a single command.
Open Active File in New Window Ctrl + K, O
3. New Window with Same File [3]
As AllenBooTung also pointed out, you can open/drag any file in a separate blank instance.
Open New Window Ctrl + Shift + N
Drag tab into new window
4. Open Workspace and Folder Simultaneously [4]
VS Code will not allow you to open the same folder in two different instances, but you can use Workspaces to open the same directory of files in a side by side instance.
Open Folder Ctrl + K,Ctrl + O
Save Current Project As a Workspace
Open Folder Ctrl + K,Ctrl + O
For any workaround, also consider setting setting up auto save so the documents are kept in sync by updating the files.autoSave setting to afterDelay, onFocusChange, or onWindowChange
When I want to split the screens I usually do one of the following:
open new window with: Ctrl+Shift+N
and after that I drag the current file I want to the new window.
on the File explorer - I hit Ctrl+Enter on the file I want - and then this file and the other file open together in the same screen but in split mode, so you can see the two files together. If the screen is wide enough this is not a bad solution at all that you can get used to.
With Visual Studio 1.43 (Q1 2020), the Ctrl+K then O keyboard shortcut will work for a file.
See issue 89989:
It should be possible to e.g. invoke the "Open Active File in New Window" command and open that file into an empty workspace in the web.
If the accepted answer isn't working for you, for example, your shortcut key may have been changed to do other things. You can launch the command input by Ctrl + Shift + P, then type 'new window' and you will see the result File: Open active tab in a new window, and select it.
Just an update, Feb 1, 2019: cmd+shift+n on Mac now opens a new window where you can drag over tabs. I didn't find that out until I when through KyleMit's response and saw his key mapping suggestion was already mapped to the correct action.
Press Command+K (wait, it will wait for pressing any key which you can see in the below bar) then press O.
So, it is Cmd+k+ O(space represents little wait).
I found a way to achieve the "Duplicate Workspace in New Window" workflow from #mbomb007's workarounds via the command line:
Normally code --new-window <path-to-folder> will not open a new window if that folder is the root of an existing window.
code --new-window <path-to-some-file> followed by code --add <path-to-folder> does the trick. I put a 1s delay between those commands.
Issue #2686 was closed with a recommendation for users to use the "Duplicate Workspace in New Window" workflow, but didn't include a CLI solution. I would have posted this workaround there, but it's locked.
I wanted to use my second screen for viewing a preview of a document. None of the suggestions worked well since the preview was not updated in the second window, even when the workspace was duplicated and autosave enabled.
My workaround was to simply increase the size of the window to span both screens, and use the standard split tab.
To expand one window across two screens, I recommend Microsoft PowerToys. The FancyZones feature can be configured to allow zones to span across monitors, so a custom canvas can be created to quickly expand a single window to both screens.
You can also hit Win+Shift+[n]. N being the position the app is in the taskbar. Eg if it's pinned as the first app hit WIn+Shift+1 and windows will open a new instance and then you can drag the tab over to the new window.
Most convenient workaround for me so far.
If you are using the excellent
VSCode for Mac, 2020
simply tap Apple-Shift-N (as in "new window")
Drag whatever you want there.