Thanks to this great plugin : Origami
I am able to obtain the following layout :
How could I save this view to call it from the view/layout menu ?
You can get the layout data from the Auto Save Session.sublime-session
file, under the "layout":
key. This file is in standard JSON format, and can be opened in ST2 just fine (select View->Syntax->JavaScript->JSON
for syntax highlighting if you want). For OSX, this file is (probably, I'm not in front of my Mac at the moment to verify) located in ~/Library/Application Support/Sublime Text 2/Settings
- it should be in the same directory as the Packages/
folder where plugins etc. are stored.
So, to make a keyboard shortcut, set up your Origami layout, then perhaps move some files around, search for some text, anything to update the Auto Save Session.sublime-session
file. It may already have updated after changing your layout, so check the time stamp to make sure. Then, open the file and search for layout
. Copy the contents of the key - the "cells":
, "cols":
and "rows":
keys inside the curly braces, as well as the curly braces themselves. Then, open Sublime Text 2->Preferences->Key Bindings-User
and add the following to it (include the square brackets if you don't have anything in this file yet, omit them if you already do. If you already do, make sure to add a comma ,
after the last curly brace of the item before):
[
{
"keys": ["alt+shift+o"],
"command": "set_layout",
"args":
|
}
]
Set your cursor where I put the |
character after "args":
(make sure you delete the |
) and paste in the contents of the "layout":
key from Auto Save Session.sublime-session
you copied earlier. Save the file, and you should now have a keyboard shortcut AltShiftO (O for Origami) that will restore your layout for you. If you have more than one layout you'd like to save, repeat the steps above, and just change the "keys":
value to another key combination. If you have a lot of plugins, I highly recommend @skuroda's FindKeyConflicts
plugin, which is available through Package Control under the same name. With it you can get a full list of all current key mappings, so if you're planning on assigning a new one you can check to see if it's already taken. The plugin does more, as well, so if you're a plugin dev, or just a customization/macro geek like me, it's really quite useful.
As a caveat, with the complexity of the layout you displayed above, the "layout":
key is going to be quite large and complex, and is made larger by the fact that each value in the "cells":
, "cols":
and "rows":
keys is on its own line. I don't know enough regex to clean everything up automatically, but I'm sure it can be done.
来源:https://stackoverflow.com/questions/17620503/save-panes-layout-generated-by-origami-in-sublime-text-2