Skip to content

Instantly share code, notes, and snippets.

@mattst mattst/MoveTabInGroup.py
Last active Oct 27, 2018

Embed
What would you like to do?
An ST plugin to move the active buffer's tab left and right on the tab bar.
#
# Name: MoveTabInGroup
# Requirements: Plugin for Sublime Text v2 and v3
# Written by: mattst - https://github.com/mattst
# ST Command: move_tab_in_group
# Arg Required: direction: "left" or "right"
# Description: An ST plugin to move the active buffer's
# tab left and right on the tab bar.
#
import sublime
import sublime_plugin
class MoveTabInGroupCommand(sublime_plugin.WindowCommand):
"""
An ST plugin to move the active buffer's tab left and right on the tab bar.
"""
def run(self, direction):
active_sheet = self.window.active_sheet()
if not active_sheet:
return
group, tab_pos = self.window.get_sheet_index(active_sheet)
num_tabs_in_group = len(self.window.sheets_in_group(group))
if tab_pos < 0 or num_tabs_in_group < 2:
return
elif direction == "left":
new_tab_pos = tab_pos - 1
if new_tab_pos < 0:
new_tab_pos = num_tabs_in_group - 1
elif direction == "right":
new_tab_pos = tab_pos + 1
if new_tab_pos >= num_tabs_in_group:
new_tab_pos = 0
else:
return
self.window.set_sheet_index(active_sheet, group, new_tab_pos)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.