Sublime Forum

Start sublime text with single layout

#1

When I split the layout and restart sublime text 4, sublime text starts with a split layout instead of a single layout. How can I force sublime text to always start with a single layout ?

I looked in the settings but I didn’t find anything. Can this be solved by changing a setting ?

I tried to create following plugin but it doesn’t work :

import sublime, sublime_plugin

class SingleLayoutListener(sublime_plugin.EventListener):
  def on_exit(self):
    sublime.active_window().run_command('set_layout', {"cols": [0.0, 1.0], "rows": [0.0, 1.0], "cells": [[0, 0, 1, 1]] } )

Why is my plugin not working ?

0 Likes

#2

For the plugin, https://github.com/sublimehq/sublime_text/issues/4457 may be related. But I am on bed already so I can’t do a test.

0 Likes

#3

I tried using on_init instead of on_exit. On_init works. See here the code :

import sublime, sublime_plugin

class SingleLayoutListener(sublime_plugin.EventListener):
  def on_init(self, views):
    sublime.active_window().run_command('set_layout', {"cols": [0.0, 1.0], "rows": [0.0, 1.0], "cells": [[0, 0, 1, 1]] } )
0 Likes

#4

So it ends up image

0 Likes

#5

The hot_exit setting (which defaults to being turned on) tells Sublime to restore on startup the state that it had when it quit, so by having it turned on, you get a split layout at startup because that’s what was the state when you quit.

Set hot_exit to false in your settings if you don’t want state to be restored (note however that this refers to all state; you will always start with exactly one empty window).

0 Likes

#6

I tried to put hot_exit to false, I also tried to put it to “disabled”. But in both cases, when I split the layout and restart sublime text, sublime text starts with a splitted layout.

See here my settings :

{
  "convert_tabspaces_on_save": true,
  "detect_indentation": false,
  "font_size": 11,
  "highlight_modified_tabs": true,
  "hot_exit": false,
  "ignored_packages":
  [
    "Vintage",
  ],
  "remember_open_files": false,
  "show_encoding": true,
  "show_line_endings": true,
  "tab_size": 2,
  "translate_tabs_to_spaces": true,
  "trim_trailing_white_space_on_save": true,
  "tab_completion": false,
  "theme": "auto",
}
0 Likes

#7

With hot_exit set to false, you should always start with a single window containing only a single file group. Can you provide a screenshot of what you’re seeing on a fresh start of Sublime?

0 Likes

#8

I have the same problem.
This already didn’t work in version 3 as far as I can remember? No matter which layout you choose, sublime remembers it at the next start (with "hot_exit": false or now with version 4 "hot_exit": "disabled").

0 Likes

#9

I believe what they meant is this:

0 Likes

#10

Yes, but in the absence of a session that saved the layout of a window as two columns or a package/plugin that specifically forces windows to switch their layout (as the sample plugin above is doing) , brand new windows are always created with a single file group in them.

For example, Start ST4 in safe mode; you get a window with a single layout in it.

The fact that setting hot_exit to a value to turn it off still results in a split layout when Sublime is starting is an indication that something is interfering and forcing it to happen.

0 Likes

#11

As I mentioned in Open up ST4 to edit 1 file should open just 1 column I tested with a clean sublime install (no packages, no license, no settings). When you open ST4, press alt+shift+2 and exit, the next time you open up ST4 the dual pane is there. I would be nice if you open up a file in ST4 ( so no project) it can always open up in a default 1 pane view.

0 Likes

#12

What you’re describing here is what I mentioned above; if you have hot_exit turned on, then the state of the entire interface is persisted when you quit and restored to what it was when you restart, which includes things like the window layout.

To always have Sublime open a single empty window, turn hot_exit off.

0 Likes

#13

@OdatNurd I really appreciate your endless effort to reply to people. I must be one of those that keep on missing the point.
Each time I open up the settings file, it opens up a window in two panes. Closing it and opening sublime again makes sublime laugh at me with a … double pane.

In my settings I tried:

  • // “hot_exit”:“off”
  • “hot_exit”:false
  • “hot_exit”:“disabled”

none of those work.
I was kind of hoping to get my hands on a fast editor, but configuring it seems to take ages :slight_smile:

0 Likes

#14

Well apologies but yes, apparently the window layout is persisted from session to session regardless of whether the options for persisting layout are set or not (which frankly I would consider a bug except after a bunch of testing of historical versions, it would appear it’s always done this).

In which case you want a plugin like the one outlined above that forces the layout. You also definitely want hot_exit to be turned off because otherwise you’re going to get other things remembered like the number of windows, what files you had open, unsaved changes, undo state, etc. Presumably if you only ever want a clean empty window every time you start, you want none of that.

0 Likes