10

I want a custom layout for my ST3 - specifically, I want this layout structure. Can someone tell me how can I do it ?enter image description here

Keith Hall
  • 15,362
  • 3
  • 53
  • 71
Alex Hunter
  • 212
  • 9
  • 30
  • Here's my [Layouts.sublime-commands](https://gist.github.com/mattst/64c8f3d7fbb0a7be27f38f05afb4a300) file which adds all the layouts from the `View --> Layout` menu to Sublime Text's Command Palette as well as all 4 possible combinations of 3 pane layouts. Save the raw [Layouts.sublime-commands](https://gist.githubusercontent.com/mattst/64c8f3d7fbb0a7be27f38f05afb4a300/raw/1f46a0955ca966895265e9e92c1200b5063b5c9d/Layouts.sublime-commands) file to your Sublime Text config `User` folder (or elsewhere if you know what you're doing). To use open the Command Palette and type `Set Layout...`. – mattst Jun 01 '19 at 11:00

3 Answers3

13

Although you can get your hands dirty with manually creating such a layout, probably the easiest way to pull this off would be to use a package to do it. The Origami package is one example of this.

Using that package, you can follow the following steps to get the layout that you're interested in:

  1. Select Origami: Create Pane Below command (or use the standard View > Layout > Rows: 2 menu item) to create two rows
  2. Focus the bottom pane and select Origami: Create Pane on the Right

Once you have this layout complete, you can use Origami: Save Current Layout from the command palette to save it and then easily recall it later as needed.


Assuming that you don't want to/can't install third party packages, you can also make your own customized menu item and/or key binding that will set this layout for you.

In order to add a new item to the menu, save the following text as Main.sublime-menu in your User package (use Preferences > Browse Packages if you don't know where that is):

[
    {
        "caption": "View",
        "mnemonic": "V",
        "id": "view",
        "children":
        [
            { "caption": "-", "id": "groups" },
            {
                "caption": "Layout",
                "mnemonic": "L",
                "id": "layout",
                "children":
                [
                    {
                        "caption": "Three Pane",
                        "command": "set_layout",
                        "args":
                        {
                            "cols": [0.0, 0.5, 1.0 ],
                            "rows": [0.0, 0.5, 1.0 ],
                            "cells": [
                                [0, 0, 2, 1 ],
                                [0, 1, 1, 2 ],
                                [1, 1, 2, 2 ]
                            ]
                        }
                    }
                ]
            },
        ]
    }
]

This will add a new menu entry under View > Layout called Three Pane which, when selected, will set your desired layout. Alter the value of the caption string as appropriate to change the name of the layout.

Additionally, you can add the following key binding to your custom key bindings (Preferences > Key Bindings from the menu) in order to have a hot key that does the same thing:

{
    "keys": ["alt+shift+3"],
    "command": "set_layout",
    "args":
    {
        "cols": [0.0, 0.5, 1.0 ],
        "rows": [0.0, 0.5, 1.0 ],
        "cells": [
            [0, 0, 2, 1 ],
            [0, 1, 1, 2 ],
            [1, 1, 2, 2 ]
        ]
    }
},

If this is your first custom key binding, make sure to wrap this entire text in a pair of [ and ], as the key bindings are a list of items and this represents just the key binding itself.

This reuses the default Windows/Linux key binding for three columns, so you can change that as appropriate. If you do this in combination with the menu change above, the menu will automatically display the key binding you're using as a reminder in case you forget.

For reference, the set_layout command takes the same layout argument as the (officially undocumented) window.set_layout() API call. There is unofficial documentation on that method that explains how this works, although here I cheated and used Origami to create the layout.

OdatNurd
  • 21,371
  • 3
  • 50
  • 68
3

1st Option:

Install the package more layouts and press ALT + SHIFT + 6

Here you can see the package and some example of a lot of layouts:

https://packagecontrol.io/packages/More%20Layouts

Example with my sublime text 3:enter image description here

If you dont know how to install packages here you can find out how:

https://packagecontrol.io/installation

2nd Option:

Open the console using CTRL + `

And type this command:

window.set_layout({'cols': [0.0, 0.5, 1.0], 'cells': [[0, 0, 1, 1], [1, 0, 2, 1], [0, 1, 2, 2]], 'rows': [0.0, 0.5, 1.0]})

That should do the trick for that exact layout.

Unknow0059
  • 101
  • 3
  • 11
Yorki Bonilla
  • 535
  • 2
  • 9
0

I made a diagram for me to understand how set_layout constructs a layout from the values given to it, and figured I'd share. diagram Yes, X really is cols and Y really is rows. That is unintuitive.

Think of it like this: the vertical lines (columns) grow from points in the horizontal axis, and the horizontal lines (rows) grow from points in the vertical axis.

I hope it's understandable and helpful.

Unknow0059
  • 101
  • 3
  • 11