Skip to content

Instantly share code, notes, and snippets.

@ryanberckmans
Last active May 24, 2021 05:25
Show Gist options
  • Save ryanberckmans/431282582265de7a5321 to your computer and use it in GitHub Desktop.
Save ryanberckmans/431282582265de7a5321 to your computer and use it in GitHub Desktop.
Sublime Text 3, ST3, cycle group tabs, switch tabs in same group, ctrl-tab in same layout
0. Install Package Control https://packagecontrol.io/installation
1. Install https://github.com/SublimeText/AAAPackageDev
2. Open command palette (apple-shift-P on OSX), and search for 'Plugin' -> AAAPackageDev: New Plugin
3. paste contents of prev_next_view_in_group.py and save as prev_next_view_in_group.py.
AAAPackageDev will automatically select the correct folder
(which is approximately ~/.../Sublime Text 3/Pacakges/User/)
4. add key bindings to User Key Bindings
ctrl+tab and ctrl+shift+tab will now cycle through your open tabs,
in order as expected, and won't leave the current layout group.
{ "keys": ["ctrl+tab"], "command": "prev_next_view_in_group", "args":{"dir": 1} },
{ "keys": ["ctrl+shift+tab"], "command": "prev_next_view_in_group", "args":{"dir": -1} }
import sublime, sublime_plugin
class PrevNextViewInGroupCommand(sublime_plugin.TextCommand):
def run(self, edit, dir):
w = sublime.active_window()
group_views = w.views_in_group(w.active_group())
views_count = len(group_views)
curr_view = w.active_view()
curr_view_index = w.get_view_index(curr_view)[1]
next_view = group_views[(curr_view_index + dir) % views_count]
w.focus_view(next_view)
@RheingoldRiver
Copy link

This seems to be not required anymore in ST4, as the native behavior now cycles within the same group!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment