Sublime Forum

View->Layout Access from Goto Anything

#1

Totally noob to Sublime so I apologize for the basic question. I toggle between different view->layout options from primarily single column. My brain has a tough time with remembering key-shortcuts across so many programs and systems so I find Goto Anything simply the greatest thing I have every experienced. But I’m not finding the layout options in the Goto Anything menu (I can find the view options for toggling the sidebar etc but nothing for the layouts). I am assuming this is a noob user error, so wondering where it is and why i cant find it? And it for whatever reason it might not be in the menu, is the goto menu user modifiable so i can add it?

0 Likes

#2

Welcome to the wonderful world of Sublime!

Just as a quick aside on terminology, the panel you’re talking about is the Command Palette; Goto Anything is a similar mechanism for navigating through files which is very similar visually and operationally to the command palette. I mention this only so that you’re not confused going forward as you clearly know what key is opening the thing you’re looking for commands in. :slightly_smiling:

The options that you’re talking about are included in the menu under View > Layout and bound to default key shortcuts, but indeed are not in the command palette along with other commands. Fortunately, as with most things in Sublime, this is entirely customizable so you can add those options there if you wish.

To directly answer your question, you can save the following to a file named Default.sublime-commands in your User package (use Preferences > Browse Packages... to find where that is if you’re not sure).

[
    {
        "caption": "Layout: Single",
        "command": "set_layout",
        "args": {"cols": [0.0, 1.0], "rows": [0.0, 1.0], "cells": [[0, 0, 1, 1]] }
    },
    {
        "caption": "Layout: Columns: 2",
        "command": "set_layout",
        "args": {"cols": [0.0, 0.5, 1.0], "rows": [0.0, 1.0], "cells": [[0, 0, 1, 1], [1, 0, 2, 1]] }
    },
    {
        "caption": "Layout: Columns: 3",
        "command": "set_layout",
        "args": {"cols": [0.0, 0.33, 0.66, 1.0], "rows": [0.0, 1.0], "cells": [[0, 0, 1, 1], [1, 0, 2, 1], [2, 0, 3, 1]] }
    },
    {
        "caption": "Layout: Columns: 4",
        "command": "set_layout",
        "args": {"cols": [0.0, 0.25, 0.5, 0.75, 1.0], "rows": [0.0, 1.0], "cells": [[0, 0, 1, 1], [1, 0, 2, 1], [2, 0, 3, 1], [3, 0, 4, 1]] }
    },
    {
        "caption": "Layout: Rows: 2",
        "command": "set_layout",
        "args": {"cols": [0.0, 1.0], "rows": [0.0, 0.5, 1.0], "cells": [[0, 0, 1, 1], [0, 1, 1, 2]] }
    },
    {
        "caption": "Layout: Rows: 3",
        "command": "set_layout",
        "args": {"cols": [0.0, 1.0], "rows": [0.0, 0.33, 0.66, 1.0], "cells": [[0, 0, 1, 1], [0, 1, 1, 2], [0, 2, 1, 3]] }
    },
    {
        "caption": "Layout: Grid: 4",
        "command": "set_layout",
        "args": {"cols": [0.0, 0.5, 1.0], "rows": [0.0, 0.5, 1.0], "cells": [[0, 0, 1, 1], [1, 0, 2, 1], [0, 1, 1, 2], [1, 1, 2, 2] ] }
    }
]

This is directly what is in the menu file Default/Main.sublime-menu for these options, except that the caption text has been modified to include Layout: so that they’re easier to find. You can modify that as desired and/or remove any of the options that you don’t want.

The only thing to keep in mind is that the file needs to be valid JSON. The syntax highlighting should tell you if you’ve gone astray, though.

If you haven’t already, I highly recommend the Unofficial Documentation, which provides a lot of information on how everything works behind the scenes.

For a task like this, something like PackageResourceViewer is exceedingly handy as well. This is what I used to get the contents of the menu, for example.

4 Likes

#3

Just to clarify @OdatNurd first paragraph:

  • ctrl+p → Goto Anything
  • ctrl+shift+p → Command Palette
2 Likes

#4

THANK YOU!!! And thanks for correcting/clarifying goto anything vs. command palette.

0 Likes