Last active
May 24, 2021 05:25
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "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} } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
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
Based on this plugin for ST2 https://gist.github.com/vitaLee/3009871