Here’s the code I’m using, in case others find it useful.
It can be bound to a single key which will make a split view into the current file, just like dragging the horizontal splitter in other editors, or close the split view if it’s open.
This is meant for somebody who uses the Single layout. If you are already using other layouts, then you’ll have to look into more elaborate plugins, such as Origami.
[code]import sublime_plugin
class SplitPaneCommand(sublime_plugin.WindowCommand):
def run(self):
w = self.window
if w.num_groups() == 1:
w.run_command(‘set_layout’, {
‘cols’: [0.0, 1.0],
‘rows’: [0.0, 0.33, 1.0],
‘cells’: [0, 0, 1, 1], [0, 1, 1, 2]]
})
w.run_command(‘clone_file’)
w.run_command(‘move_to_group’, {‘group’: 1})
w.focus_group(1)
else:
w.focus_group(1)
w.run_command(‘close’)
w.run_command(‘set_layout’, {
‘cols’: [0.0, 1.0],
‘rows’: [0.0, 1.0],
‘cells’: [0, 0, 1, 1]]
})
[/code]