public
Last active

Sublime : 2 Columns Layout Management

  • Download Gist
Default (OSX).sublime-keymap
JSON
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
[
 
{ "keys" : [ "alt+1" ], "command" : "focus_group", "args" : { "group" : 0 } },
 
{ "keys" : [ "alt+2" ], "command" : "focus_group", "args" : { "group" : 1 } },
 
{ // workspace left
"keys" : [ "ctrl+alt+super+left" ],
"command" : "run_multiple_commands",
"args" : {
"commands" : [
{
"command" : "set_layout",
"args" : {
"cols" : [ 0.0, 0.80, 1.0 ],
"rows" : [ 0.0, 1.0 ],
"cells" : [ [ 0, 0, 1, 1 ], [ 1, 0, 2, 1 ] ]
},
"context" : "window"
},
{ "command" : "focus_group", "args" : { "group" : 0 }, "context" : "window" }
]
}
},
 
{ // fetch from the right
"keys" : [ "ctrl+alt+left" ],
"command" : "run_multiple_commands",
"args" : {
"commands" : [
{ // give visual feedback due to change of focus, if coming from the right
"command" : "set_layout",
"args" : {
"cols" : [ 0.0, 0.80, 1.0 ],
"rows" : [ 0.0, 1.0 ],
"cells" : [ [ 0, 0, 1, 1 ], [ 1, 0, 2, 1 ] ]
},
"context" : "window"
},
{ "command" : "focus_group", "args" : { "group" : 1 }, "context" : "window" },
{ "command" : "move_to_group", "args" : { "group" : 0 }, "context" : "window" },
{ "command" : "focus_group", "args" : { "group" : 0 }, "context" : "window" }
]
}
},
 
{ // put to the right
"keys" : [ "ctrl+alt+right" ],
"command" : "run_multiple_commands",
"args" : {
"commands" : [
{ // give visual feedback due to change of focus, if coming from the right
"command" : "set_layout",
"args" : {
"cols" : [ 0.0, 0.80, 1.0 ],
"rows" : [ 0.0, 1.0 ],
"cells" : [ [ 0, 0, 1, 1 ], [ 1, 0, 2, 1 ] ]
},
"context" : "window"
},
{ "command" : "focus_group", "args" : { "group" : 0 }, "context" : "window" },
{ "command" : "move_to_group", "args" : { "group" : 1 }, "context" : "window" },
{ "command" : "focus_group", "args" : { "group" : 0 }, "context" : "window" }
]
}
},
 
{ // workspace right
"keys" : [ "ctrl+alt+super+right" ],
"command" : "run_multiple_commands",
"args" : {
"commands" : [
{
"command" : "set_layout",
"args" : {
"cols" : [ 0.0, 0.20, 1.0 ],
"rows" : [ 0.0, 1.0 ],
"cells" : [ [ 0, 0, 1, 1 ], [ 1, 0, 2, 1 ] ]
},
"context" : "window"
},
{ "command" : "focus_group", "args" : { "group" : 1 }, "context" : "window" }
]
}
},
 
{ // fetch from the left
"keys" : [ "alt+super+right" ],
"command" : "run_multiple_commands",
"args" : {
"commands" : [
{ // give visual feedback due to change of focus, if coming from the left
"command" : "set_layout",
"args" : {
"cols" : [ 0.0, 0.20, 1.0 ],
"rows" : [ 0.0, 1.0 ],
"cells" : [ [ 0, 0, 1, 1 ], [ 1, 0, 2, 1 ] ]
},
"context" : "window"
},
{ "command" : "focus_group", "args" : { "group" : 0 }, "context" : "window" },
{ "command" : "move_to_group", "args" : { "group" : 1 }, "context" : "window" },
{ "command" : "focus_group", "args" : { "group" : 1 }, "context" : "window" }
]
}
},
 
{ // put to the left
"keys" : [ "alt+super+left" ],
"command" : "run_multiple_commands",
"args" : {
"commands" : [
{ // give visual feedback due to change of focus, if coming from the left
"command" : "set_layout",
"args" : {
"cols" : [ 0.0, 0.20, 1.0 ],
"rows" : [ 0.0, 1.0 ],
"cells" : [ [ 0, 0, 1, 1 ], [ 1, 0, 2, 1 ] ]
},
"context" : "window"
},
{ "command" : "focus_group", "args" : { "group" : 1 }, "context" : "window" },
{ "command" : "move_to_group", "args" : { "group" : 0 }, "context" : "window" },
{ "command" : "focus_group", "args" : { "group" : 1 }, "context" : "window" }
]
}
}
 
]
run-multiple-commands.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
# run_multiple_commands.py
 
import sublime, sublime_plugin
 
# Takes an array of commands (same as those you'd provide to a key binding) with
# an optional context (defaults to view commands) & runs each command in order.
# Valid contexts are 'text', 'window', and 'app' for running a TextCommand,
# WindowCommands, or ApplicationCommand respectively.
 
class RunMultipleCommandsCommand(sublime_plugin.TextCommand):
def exec_command(self, command):
if not 'command' in command:
raise Exception('No command name provided.')
 
args = None
if 'args' in command:
args = command['args']
 
# default context is the view since it's easiest to get the other contexts
# from the view
context = self.view
if 'context' in command:
context_name = command['context']
if context_name == 'window':
context = context.window()
elif context_name == 'app':
context = sublime
elif context_name == 'text':
pass
else:
raise Exception('Invalid command context "'+context_name+'".')
 
# skip args if not needed
if args is None:
context.run_command(command['command'])
# uncomment the next line, if you want to add a delay to the execution
# sublime.set_timeout( lambda: context.run_command(command['command']), 2000 )
else:
context.run_command(command['command'], args)
# uncomment the next line, if you want to add a delay to the execution
# sublime.set_timeout( lambda: context.run_command(command['command'], args), 2000 )
 
def run(self, edit, commands = None):
if commands is None:
return # not an error
for command in commands:
self.exec_command(command)

The run_multiple_commands.py has been developed by Nilium - see http://www.sublimetext.com/forum/viewtopic.php?f=5&t=8677 for a discussion.

Works on ST3, thanks for sharing mate!

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.