Sublime Forum

Keyboard shortcut for switching between fullscreen sublime projects, macOS

#1

NOTE - SEE ATTACHED IMAGE FOR CLARIFICATION

Frustratingly cannot find a way to do this. Don’t really care whether I use “seperate” windows (previously asked here) or the new sierra tabs (discussed here), but neither seem to support keyboard shortcuts in sublime (cmd + ~ and control + tab don’t work). Any help much appreciated.

2 Likes

#2

Hard to understand you… Are you on windows or macOS?

In window, it’s alt+tab to swap window (not just Sublime Text window), and ctrl+tab to swap tab in sublime text

0 Likes

#3

Ah yes, have now edited title for clarity - am on macOS (was referring to application windows not the operating system). Appreciate input control tab does not work for me. Does it work for you?

1 Like

#4

I’m understanding you mean swapping tabs in Sublime Text.

The command is next_view_in_stack, and it’s bind to ctrl+tab in the keymap. I no there is a weird thing with mac os: cmd is super, so I guess ctrl is the same. But I’m not sure.

I’ve seen in your previous edit that you said

[control+tab] switches between applications, not different instances of the same application.

ctrl+tab doesn’t swap between Sublime Text window instances, just windows in general. (on windows, i’m 100% sure, on mac os, “just” pretty sure).

0 Likes

#5

Thanks for input, can confirm from testing that [control tab] switches between file tabs but NOT project tabs (the new sierra functionality I believe). I am looking for a keyboard shortcut to switch between fullscreen projects, either in project tabs or seperate fullscreen windows.

I will edit the original question with an image for clarification.

1 Like

#6

Did you ever find an answer to this? I too find it extremely frustrating.

0 Likes

#7

No answer yet am afraid. Am currently just making do with having 2 fullscreen windows, knowing where they are and using control + left / right - not a nice solution but all I can figure out.

0 Likes

#8

Sublime Text doesn’t specifically integrate with macOS Sierra tabs. It seems that Sierra will end up placing full “windows” within tabs which gives you the functionality you have so far. However, there is no integration with Sublime Text itself, or key bindings.

Does ```cmd+```` work? That switches between windows in an application on OS X, so it would make sense to me if that worked for “tab-ified” windows also.

0 Likes

#9

This should work for switching between two tabs. If you want switching between tabs in multiple windows, or switching between more than two tabs, someone will need to write the extra AppleScript to enumerate windows and cycle between more than just one window / two tabs, but this should lay a framework. It might even be possible to bind “new window tab” and “close window tab” hotkeys using a technique similar to this.

  1. Copy the script at the end of this post into Packages/User/mactab.py

  2. Open System Preferences and browse to Security & Privacy -> Privacy -> Accessibility

  3. Click the little plus (+) button under the list of apps “Allow the apps below to control your computer”

  4. Browse to the Sublime Text app bundle (maybe /Applications/Sublime Text) and add it.

  5. Close all but one Sublime Text window, and open a window tab (must be forced using System Preferences -> Dock -> Prefer tabs when opening documents)

  6. In the Sublime console, run window.run_command('switch_mac_tab')

  7. You can bind a key to the switch_mac_tab command to cycle.

Script:

import sublime_plugin
import subprocess
import threading

switch_tab = '''
tell application "System Events"
    tell tab group 1 of window 1 of application process "Sublime Text"
        click radio button 1
    end tell
end tell
'''

def run_osa(script):
    p = subprocess.Popen('/usr/bin/osascript', stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    script = script.encode('utf8')
    out = p.communicate(script)
    print('ran osascript', out)

class SwitchMacTab(sublime_plugin.WindowCommand):
    def run(self):
        t = threading.Thread(target=run_osa, args=(switch_tab,))
        t.daemon = True
        t.start()

if __name__ == '__main__':
    run_osa(switch_tab)
0 Likes

#10

Thanks a lot for putting that script together. Probably a little bit beyond what Im comfortable with on a work computer (due to system level changes / my own lack of understanding) but sure will be a great workaround for others

0 Likes

#11

I’ve been struggling with the window switching for a while, hoping that this was addressed thus far, but nothing yet that I can find.

Similar to the original post, but not even using tabs:

  • Two projects with two fullscreen windows
  • CMD + ` does not switch between application windows

It works on practically any other application I use, but Sublime is where I spend most of my time.

@wbond, do you have any updates on this issue being fixed at some point? Thanks.

0 Likes

#12

Old thread but I wanted to share something that worked perfectly for me for switching between OS tabs (different project tabs) (macOS only):

  1. Go to System Preferences > Keyboard > Shortcuts
  2. Select App Shortcuts on the left pane
  3. Click the plus sign underneath the right pane
  4. Recommended: select the application Sublime Text
  5. Type the exact menu title (Show Previous Tab)
  6. Pick the shortcut and click Add
  7. Repeat 3-6 for Show Next Tab command shortcut.

I only had a small issue: the first shortcut I wanted to use didn’t seem work. Maybe there are some restrictions about it. I got it working with cmd + shift + alt + ←/→ which correlates with the current cmd + alt + ←/→ for switching same-project tabs (buffers).

Source: https://github.com/sublimehq/sublime_text/issues/2740#issuecomment-509895201

1 Like

#13

Thanks for recommending using System Preferences > Keyboard > Shortcuts, this worked for me and I just mapped the default MacOS key commands to make this work.

FWIW, it’s odd that Sublime Text doesn’t respect the default MacOS keyboard shortcuts:

  • COMMAND+`
  • SHIFT+COMMAND+`

Edit

Actually, I found a much better solution as this issue is related to Sublime Text supporting MacOS Prefer Tabs feature which allow windows to be opened in tabs.

I edited the following file:
~/Library/Application Support/Sublime Text 3/Packages/User/Preferences.sublime-settings

And added this setting:
"native_tabs": "disabled",

Now, when I open a new folder it always opens in a new Sublime Text window.

0 Likes