将 Origami 生成的窗格布局保存在 Sublime Text 2 中 [英] Save panes layout generated by Origami in Sublime Text 2

查看:39
本文介绍了将 Origami 生成的窗格布局保存在 Sublime Text 2 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

感谢这个伟大的插件:的FindKeyConflicts 插件,可通过 包控制 同名.有了它,您可以获得所有当前键映射的完整列表,因此如果您打算分配一个新的键映射,您可以检查它是否已经被使用.该插件的功能也更多,因此如果您是插件开发者,或者像我这样的自定义/宏极客,它真的非常有用.

需要注意的是,由于上面显示的布局的复杂性,"layout": 键将变得非常大和复杂,并且由于每个值在"cells":"cols":"rows": 键在它自己的行上.我不知道足够的正则表达式来自动清理所有内容,但我确信它可以完成.

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.

这篇关于将 Origami 生成的窗格布局保存在 Sublime Text 2 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆