- Code: Select all
<binding key="ctrl+m,/(\d)/" command="moveTab $1"/>
class MoveTab(sublimeplugin.TextCommand):
def run(self, view, args):
win = view.window()
group, tab = win.getViewPosition(view)
win.setViewPosition(view, group, int(args[0]))
print "MoveTab from %d to %s: end position is %d" % (tab, args[0], win.getViewPosition(view)[1])
I opened a new empty editor window, created four new tabs and named them 1, 2, 3 and 4. Then I selected tab 4 and typed ctrl+m,2,ctrl+m,1,ctrl+m,0. Now all is good -- the tab is moved as expected (one step left each time) and console shows:
- Code: Select all
MoveTab from 3 to 2: end position is 2
MoveTab from 2 to 1: end position is 1
MoveTab from 1 to 0: end position is 0
Here comes the problem: continue moving the tab with ctrl+m,1,ctrl+m,2,ctrl+m,3. With the first command, tab does not move and after that the tab is always one position 'behind'. You can also see this from the console:
- Code: Select all
MoveTab from 0 to 1: end position is 0
MoveTab from 0 to 2: end position is 1
MoveTab from 1 to 3: end position is 2