lukas.pukenis
lukas.pukenis

Reputation: 13597

How can I save/restore window layouts in VS Code?

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).

Upvotes: 18

Views: 12592

Answers (5)

starball
starball

Reputation: 52070

As for builtin VS Code features at the time of this writing for window layout, the best you can get is along the lines of the following commands in the command palette (a couple of "hardcoded" presets):

  • View: Two Rows Editor Layout
  • View: Two Rows Right Editor Layout
  • View: Three Rows Editor Layout
  • View: Single Column Editor Layout
  • View: Toggle Centered Layout
  • View: Two Columns Editor Layout
  • View: Two Columns Bottom Editor Layout
  • View: Three Columns Editor Layout
  • View: Grid Editor Layout (2x2)

You can also change the keybindings for those things using the following command IDs:

workbench.action.editorLayoutSingle
workbench.action.editorLayoutThreeColumns
workbench.action.editorLayoutThreeRows
workbench.action.editorLayoutTwoByTwoGrid
workbench.action.editorLayoutTwoColumns
workbench.action.editorLayoutTwoColumnsBottom
workbench.action.editorLayoutTwoRows
workbench.action.editorLayoutTwoRowsRight

There have been several requests in the past to get a layout store/recall feature added to VS Code, which are all now closed (I don't think this is an exhaustive list):


As for non-builtin solutions for window layout, you could look for extensions provided related features. I've seen several people mention ctf0.save-editors-layout (I have no affiliation with this extension). I haven't tried it for myself so I'm not necessarily vouching for it- just mentioning it.


As for saving and restoring open editors, see In VS Code, Store a group of file tabs so that I can restore a specific environment in the future.

Upvotes: 5

dev_hero
dev_hero

Reputation: 350

Open the Command Palette

View -> Command Palette...

or press

CTRL+SHIFT+P

then search for layout and make visible/invisible the panel as your needs

enter image description here enter image description here

Upvotes: 1

tSuNOOPY
tSuNOOPY

Reputation: 21

You can try this vscode extension: https://marketplace.visualstudio.com/items?itemName=ctf0.save-editors-layout

Upvotes: 2

KeyC0de
KeyC0de

Reputation: 5277

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.

Upvotes: 5

bArraxas
bArraxas

Reputation: 664

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 :)

Upvotes: 1

Related Questions