Hi,
I’m trying to develop a plugin to automate creation of split views within the editor. In Sublime Text this is exposed through the concepts of ‘groups’. I can use
sublime.Window.active_group()
sublime.Window.num_groups()
sublime.Window.focus_group(group)
sublime.Window.set_view_index(view, group, index)
To move views between existing ‘groups’, but can’t seem to figure out how to create new ones. Here is my attempt at switching to the next active group in my plugin (which works):
class NextGroupCommand(sublime_plugin.TextCommand):
def run(self, edit):
st_window = self.view.window()
# get new group to move to
new_grp = st_window.active_group() + 1
if new_grp >= st_window.num_groups():
new_grp = 0
# move to new group
st_window.focus_group(new_grp)
I want to also be able to create a new group and then create a new view into the current file in that group. Here is my (non-working) attempt:
class SplitLeftRightCommand(sublime_plugin.TextCommand):
def run(self, edit):
st_window = self.view.window()
print st_window.active_group()
print st_window.num_groups()
if st_window.num_groups() > 1:
st_window.run_command('layoutSingle')
st_window.run_command('layoutDoubleHoriz')
print st_window.num_groups()
st_window.run_command('newViewIntoFile')
st_window.set_view_index(st_window.active_view(), 1, 0)
st_window.focus_group(1)
The following lines don’t work, probably as I am calling them in the wrong way:
st_window.run_command('layoutSingle')
st_window.run_command('layoutDoubleHoriz')
Does anyone have any idea how to create new splits (or ‘groups’) in the editor?
Thanks for your help!
Best,
Ken