Home Download Buy Blog Forum Support

Where should I be storing custom layouts?

Where should I be storing custom layouts?

Postby idangazit on Sun Oct 30, 2011 6:22 am

Hey all,

Having pieced together infos from this forum and elsewhere, I found how to create a custom 3-pane layout (https://gist.github.com/1320281).

The thing is, I'm not sure where I should be keeping this layout. It appears that layouts are defined twice — once in Packages/Default/Main.sublime-menu and again in Packages/Default/Default (__PLATFORM__).sublime-keymap.

Both of the above referenced files get blown away upon update. Where should I be putting my custom layout that I can assign a keymap to it and not lose it upon upgrade?
idangazit
 
Posts: 4
Joined: Mon Feb 21, 2011 1:23 pm

Re: Where should I be storing custom layouts?

Postby stefanpausch on Sun Oct 30, 2011 8:52 am

Create the file Packages/User/Main.sublime-menu
stefanpausch
 
Posts: 19
Joined: Mon Oct 03, 2011 5:39 pm

Re: Where should I be storing custom layouts?

Postby idangazit on Mon Oct 31, 2011 7:42 am

stefanpausch wrote:Create the file Packages/User/Main.sublime-menu


OK, that raises a few questions:

Do I need to copy the entire file, or is there a way to include just my addition? The point is that updates shouldn't get screwed by the copied Packages/User/Main.sublime-menu from this version.

Do I also need to copy Default (__PLAT__).sublime-keymap?

Is it even necessary to define the layout twice? Main.sublime-menu has the caption and Default (OSX).sublime-keymap has the keys definition, but the rest is duplicate data. What's the canonical source here?

If there is some documentation on the matter, I'd appreciate being pointed in its direction—haven't succeeded in finding it so far.
idangazit
 
Posts: 4
Joined: Mon Feb 21, 2011 1:23 pm

Re: Where should I be storing custom layouts?

Postby stefanpausch on Mon Oct 31, 2011 7:56 am

Create an empty Packages/User/Main.sublime-menu file
Copy your code/layout into it, no need to duplicate
The global files are read first, the user files last. User file overwrites.

I put a 2 columns, 1 Row Layout into Packages/User/Main.sublime-menu file, which looks this now (only this code is in my file. This is not an excerpt):

Code: Select all
[{
"id": "view",
"children": [{
    "id": "layout",
    "children": [{
       "command": "set_layout",
       "caption" : "2C - 1R",
       "mnemonic": "J",
       "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, 2, 2]
          ]
       }
    }]
}]}]


Btw the files are read instant, no need to reopen sublime text2.

I got my information on this board, different websites, the documentation, etc.
I have no idea what (__PLAT__).sublime-keymap does and i guess thats the basis/canonical file which is read before the "General/Default" file.

If you insert an already existing layout, it is overwritten (I did not test this). If you add a layout with a different name (like i did) it is added to the menu.

Hope this clears things a bit up.
stefanpausch
 
Posts: 19
Joined: Mon Oct 03, 2011 5:39 pm

Re: Where should I be storing custom layouts?

Postby idangazit on Wed Nov 02, 2011 12:19 pm

Thanks Stefan — this was very helpful!

Some testing reveals that the keymap doesn't seem to work without the corresponding layout, and the layout definition must be identical or the keymap won't be applied.

In other words, if you wan to have a layout and have a keybinding for it, you have to copy the same layout in both Main.sublime-menu and Default (OSX).sublime-keymap.

One last question -- what the purpose of the 'mnemonic' argument?
idangazit
 
Posts: 4
Joined: Mon Feb 21, 2011 1:23 pm

Re: Where should I be storing custom layouts?

Postby idangazit on Wed Nov 02, 2011 12:20 pm

For posterity, I've posted my finished settings here: https://gist.github.com/1320281
idangazit
 
Posts: 4
Joined: Mon Feb 21, 2011 1:23 pm


Return to Technical Support

Who is online

Users browsing this forum: Yahoo [Bot] and 9 guests