Save Panel Layout Created by Origami in Sublime Text 2

Thanks to this wonderful plugin: Origami

I can get the following layout:

enter image description here

How do I save this view to call it from the view / layout menu?

enter image description here

+4
source share
1 answer

You can get the layout data from the Auto Save Session.sublime-session file under the "layout": key "layout": This file is in the standard JSON format and can simply be opened in ST2 (select View->Syntax->JavaScript->JSON to highlight the syntax if you want). For OSX, this file (probably I'm not in front of my Mac at the moment to check) located in ~/Library/Application Support/Sublime Text 2/Settings - it should be in the same directory as the Packages/ folder, where plugins are stored, etc.

So, to make a key combination, set up the origami layout, then maybe move some files around, find some text, something to update the Auto Save Session.sublime-session file. It may have already been updated after changing the layout, so check the timestamp to make sure. Then open the file and search for layout . Copy the contents of the key - the keys "cells": "cols": and "rows": 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 square brackets if you don’t have anything in this file yet, omit them if you already did it. Be sure to add a comma after the last curly brace of the element):

 [ { "keys": ["alt+shift+o"], "command": "set_layout", "args": | } ] 

Set the cursor where I placed the symbol | after "args": (make sure you delete | ) and paste the contents of the "layout": key "layout": from the Auto Save Session.sublime-session that you copied earlier. Save the file, and now you should have the Alt Shift O (O for origami) key combination that will restore your layout for you. If you have several layouts that you want to save, repeat the steps above and simply change the value of "keys": to another key combination. If you have many plugins, I highly recommend the @skuroda FindKeyConflicts plugin, which is available through Package Control under the same name. With it, you can get a complete list of all current key mappings, so if you plan to assign a new one, you can check if it is already done. The plugin also does more, so if you are a plugin developer or just a setup / macro wizard like me, it is really very useful.

As a warning, with the complexity of the layout that you indicated above, the "layout": key will be quite large and complex and will be increased by the fact that each value in "cells": "cols": and "rows": are in a separate line. I don't know enough regex to clear everything automatically, but I'm sure it can be done.

+5
source

Source: https://habr.com/ru/post/1491156/


All Articles