How to run VS code on more than one monitor? - visual-studio-code

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

Related

VS Code Terminal- Split for client and server folder

How to split the terminal of VSCode into two parts and run code(git command) of client and server in both individuals terminals.
I have attached an image pls see I have to achieve that only means run both folders in two terminals. I have to achieve that only.
Open the Terminal view, press the + icon to add a new terminal, select a directory to use. Once you have multiple terminal sessions, you'll see that sidebar menu listing them. Click and drag one into whatever area you wish it to occupy.
Alternatively, you can look at using a terminal multiplexer, but that's not what's being used in the screenshot you show.

VSCode - Open terminals in a separate window

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

Open Markdown Preview tab in New Window?

I have two monitors, one is my MacBook 13" that is very small to have multiple/split windows, and another one that I have my preview windows. When I'm writing a nodejs code that I store it on GitHub, I always edit some markdown files. The issue is:
I want to "detach" the Markdown Preview Windows to a "new window", so I can send it to my second monitor, so I can edit on one and see it on the other.
There are some similar questions on StackOverflow, but the solutions don't work for this case, because if I open another window/workspace and drag the preview window there, it does not update the preview when I save the original MD file... If I drag the preview window to the other monitor, it creates a "webview-panel" file.
E.g.: Markdown open a new window link
Any tips?
I tried with the default preview and the enhanced preview plugin, same results...
VS Code does not have built-in support for multi-monitor setup... sorry :)
The solution would be to simply open another window of VSCode, of the same workspace, and open there the preview of the markdown file, while keep editing in the original window.
Edit 1
Here are the actions to reproduce the solution:
Open 1st VSCode window with the project
Cmd-Shift-N to open a 2nd VSCode window
Point 2nd VSCode window to same project - but at a different root folder (as if it's the same - VSCode with just revert you to the 1st window
Open on the 2nd VSCode window the markdown file you wish to preview, and then hit Cmd-Shift-V
(Make sure you keep the tab of the markdown file open on the 2nd window as this is what VSCode Markdown preview uses to detect the file change events AFAIK)
Edit the file on the 1st window and viola, it will auto-refresh on the 2nd window preview
Edit 2
How-to video (Hosted on youtube)
Configure the 2nd monitor to have the same height as the 1st.
Stretch VS Code horizontally to span 2 monitors (am assuming this can be done on a Mac.) Now the left half of VS Code is on the 1st monitor, and the right half is on the 2nd.
Open the Markdown file in the left half of VS Code, and open the preview in the right half.
A bit of hack, but it works.
Just for those, who are still looking for a good solution to see the current changes to a Markdown file in real time in another window, you can use the Instant Markdown extension.
It provides a browser window in which the preview is displayed and also listens for changes in VSCode. Here you find more information about that package.
So I have this setup: one monitor aligned vertically for editing the source and the horizontal one one the right (or left, you can change that to your needs) shows the preview of my edit.
I use VS Code for Markdown and Tex, so its pretty cool to work like that. If you preview the stuff in the splitview you can set on the option to split it. So if you right click it and then go to Split up, your preview is down which you then can scale to your monitor size.

Visual Studio Code open tab in new window

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.

How to make Matlab editor open a new script as a tab by default, instead of a new window?

I'm used to using tabs rather than having many new windows open. I've recently changed (work) computers and now whenever I open an old script or start writing a new one it opens a new instance of the matlab editor. The question is, does anybody know how to change the default to a new tab within the same editor? (hope that makes sense).
Thanks
Open 2 scripts or more. On one of the editor windows press the circled triangle (I am sure it has a proper name):
Select Dock All in Editor.
The files should appear as tabs docked to the matlab desktop.
You can now undock the editor using the same button (you should undock the editor, not a specific file)
Any file you open now should be in a new tab.