Switch to prev/next tab in visual order (not by last active), and wrap around.
docSwitcherLeft.py:
docSwitcherLeft.py
from operator import itemgetter __author__ = "azrafe7" INDEX = 2 VIEW = 3 currView = notepad.getCurrentView() currIdx = notepad.getCurrentDocIndex(currView) tabsInView = filter(lambda item: item[VIEW] == currView, notepad.getFiles()) tabsInView.sort(key=itemgetter(INDEX)) nTabs = len(tabsInView) prevTabIdx = None for i, val in enumerate(tabsInView): if i == currIdx: prevTabIdx = tabsInView[(i + nTabs - 1) % nTabs][INDEX] break notepad.activateIndex(currView, prevTabIdx)
docSwitcherRight.py:
docSwitcherRight.py
from operator import itemgetter __author__ = "azrafe7" INDEX = 2 VIEW = 3 currView = notepad.getCurrentView() currIdx = notepad.getCurrentDocIndex(currView) tabsInView = filter(lambda item: item[VIEW] == currView, notepad.getFiles()) tabsInView.sort(key=itemgetter(INDEX)) nTabs = len(tabsInView) nextTabIdx = None for i, val in enumerate(tabsInView): if i == currIdx: nextTabIdx = tabsInView[(i + 1) % nTabs][INDEX] break notepad.activateIndex(currView, nextTabIdx)
EDIT: I've found out that due to what seems to be a bug these scripts won't work properly in the other view.
Fixed it by using BufferID instead of Index. Now works on both views:
BufferID
Index
docSwitcherLeft.py docSwitcherRight.py
Log in to post a comment.
Switch to prev/next tab in visual order (not by last active), and wrap around.
docSwitcherLeft.py
:docSwitcherRight.py
:EDIT: I've found out that due to what seems to be a bug these scripts won't work properly in the other view.
Fixed it by using
BufferID
instead ofIndex
. Now works on both views:docSwitcherLeft.py
docSwitcherRight.py