'How to set window size and position in Visual Studio Code?
Is it possible to set the VS Code window size and position, either via settings.json, though an extension, or by some other mechanism?
In Atom, I can do this in my init.coffee file as such:
atom.commands.add 'atom-workspace',
'custom:prepare-for-screencast': ->
atom.setSize(1280, 720)
atom.setPosition(37, 50)
Then I can call Prepare for screencast from the Command palette.
Solution 1:[1]
Not...yet?
https://code.visualstudio.com/docs/getstarted/settings
The closest I can find is window.newWindowDimensions, which only takes a few strings that refer to predefined geometries, although 'inherit' could serve you well in the meantime if you prime the pump by closing al your existing sessions, opening one window, sizing it to your liking, then quitting. Then all your new windows should be that size, and Visual Studio Code seems to be very well behaved with respect to resizing, just never close a resized window last, or it becomes your new default!
As for position, there appears to be nothing at all.
Solution 2:[2]
in vscode, go to
settins=>windw=>new window => new window dimension
there you are able to choose the following option to set the default dimensions, if vscode is getting opened:
inherit || offset || maximized || fullscreen
I prefer to use "inherit", i.e. open vs-code always as large as the previous one.
Solution 3:[3]
- Start Visual Studio Code.
- Click on "File"
- Click on "Preferences"
- Click on "Settings"
- Write "
window.newWindowDimensions" in the search box. - Select the value "inherit" from the drop down box.
That's it...!
Solution 4:[4]
If you're on a Mac, you can use this AppleScript snippet:
tell application "System Events" to tell process "Code"
tell window 1
set size to {1080, 720}
set position to {0, 0}
end tell
end tell
Not a general solution, but works well if you only need it when recording screencasts.
Solution 5:[5]
atom.commands.add 'atom-workspace',
'custom:prepare-for-screencast': ->
atom.setSize(1280, 720)
atom.setPosition(37, 50)
Then I can call Prepare for screencast from the Command palette.
This is really a good idea and a good feature to add to VSCode. More important to me is "atom.setSize(1280, 720)"
Hope someone will be able to port this to VSCode.
Solution 6:[6]
"window.newWindowDimensions": "maximized"
Solution 7:[7]
One way I found to solve this was by using the Developer Tools Console:
Help -> Toggle Developer Tools -> Console Tab
Type:
window.resizeTo(1900, 1060);Press Enter
Note: Tested on Windows 10, Ubuntu, OSX
Sidenote: Ubuntu had some strange behaviour bringing up the menu and developer tools. I had to open the developer tools while maximized, then undock the developer tools, then unmaximize the window, then type the command.
Solution 8:[8]
Placing the following to settings.json is a good programmatical solution.
"window.newWindowDimensions": "offset",
The comment in the defaultSettings.json file says:
- inherit: Open new windows with same dimension as last active one.
- offset: Open new windows with same dimension as last active one with an offset position.
Basically the inherit option opens new windows completely overlapping to the current window, while the offset option opens new windows with around 50 px size of offset (depends on your screen size) from top/left.
I personally prefer "offset" but these two are essentially almost same.
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 | M. Ayers |
| Solution 2 | vikbert |
| Solution 3 | Mazharul Islam |
| Solution 4 | plinehan |
| Solution 5 | Chris |
| Solution 6 | DIGITALCRIMINAL |
| Solution 7 | lukeda |
| Solution 8 | Lime |
