143

Edit: The original accepted answer is no longer valid for Mavericks. I am keeping it accepted for historical reasons, but all readers using Mavericks should use and up-vote this answer.


By default, pressing +tab will display a list of all open applications. I would like that list to only include applications in the current space, or at least give priority to applications with windows in the current space. In other words, I'd like OS X to mimic the behavior of most X window managers with respect to their workspaces/virtual desktops.

Here's my rather long-winded explanation of why I want this:

I have disabled spaces' auto-switching, and I've mapped each space to a +space # shortcut. In general, I usually have one application open per space, maximized. Since I really only ever have a half-dozen or so applications open at any time, I can easily switch between them in constant time with my left hand. The problem is that I sometimes do have two or three windows from different applications open in the same space (e.g., I often have a PDF reader open in the same space as my web browser). Let's say I have a terminal open in Space 1 and both a web browser and Preview open in Space 2. If I am in the terminal and then decide I want to open a web page, I switch to Space 2, where the web browser has focus. I then want to consult a PDF that is open in Preview, which is in the same Space but whose window is behind the web browser. If I hit +tab, however, the first option will be to take me back to Terminal in Space 1 (since Terminal most recently had focus). In the worst case, I will have to cycle through all n open applications by repeatedly pressing +tab in order to get to Preview. I want the first hit to +tab to bring me to the next application with windows in the current space, i.e., Preview.

I know that using Exposé is the more "Apple" way of handling these situations, but I want to avoid having to reach for the mouse. I know I can also use the arrow keys to select a window in Exposé, but once again that breaks my mental model of the window layering, will institute a cognitive feedback loop in the selection, and will require worst case log(n) keystrokes. As far as I know, there is no constant-time way of switching to a specific application in the current workspace using only the keyboard.

oa-
  • 7,716
ESultanik
  • 1,577
  • There are a couple of packages that offer enhancements/replacements for the built-in application switching. You might want to consider contacting the developers of one or more of these packages and let them know you would be interested in Spaces specific switching. – David Rouse Dec 29 '10 at 16:34
  • I am familiar with (although I have never used) Witch; are there any others at which I should look? – ESultanik Dec 29 '10 at 16:43
  • I've seen mentions of LiteSwitch and App Switcher, but I haven't used any of these. – David Rouse Dec 29 '10 at 20:31
  • 2
    (this isn't an answer, more of a wish/rant!) This is exactly how things should work:
    1. OSX should expose a number of 'sets' such as "all apps", "all apps in current space", "all windows in current app", "all tabs in app", etc.

    2. Several 'movements' should be supported such as "next/previous in set", "number in set", "previous in history", etc. That last one is what's often missing below the app level and is vital for switching back and forth between, e.g. a couple of different tabs

    Now let me configure any combination of the two. Please, if an apple employee is reading, make this happen

    – Bobby Jack Oct 29 '15 at 13:34

12 Answers12

53

control+F4. Cycles through the applications in that Space.
(I actually have this mapped to control+`; which I find easier to remember, being close to the cmd+`; to cycle through an application's windows.)

To change the keyboard shortcut, go to the Keyboard preferences, Keyboard Shortcuts, and Keyboard & Text Input. It's the 'Move focus to active or next window' option.

(Edit to fix the keyboard shortcuts; I didn't realise that the backtick character wasn't showing up.)

Am1rr3zA
  • 13,219
  • 14
  • 68
  • 88
Orc4hire
  • 1,241
  • 7
    I think must use CTRL+fn+F4. – Am1rr3zA Feb 01 '11 at 08:04
  • @Am1rr3zA It depends on what kind of keyboard you have. – ESultanik Feb 01 '11 at 16:44
  • Thanks; this is exactly what I want! How did you re-map it? I don't see it in the keyboard shortcuts list in System Preferences. If I were able to map this function to ⌘+tab, it would solve all of my problems. – ESultanik Feb 01 '11 at 16:46
  • It's the 4th one down in Keyboard & Text Input. I'm not sure if you can remap CMD-TAB, but you could set it to ALT-CMD-TAB or whatever you like. (To do the actual remapping, click on the ^F4 in the keyboard shortcuts list. That section should turn editable and you can press whatever key combination you want to use.) – Orc4hire Feb 01 '11 at 17:22
  • I just noticed that whatever shortcut you use, adding SHIFT will reverse the cycling order. I use CTRL-backtick so pressing CTRL-SHIFT-backtick will cycle through the windows in reverse order. – Orc4hire Feb 01 '11 at 17:25
  • 10
    I think this isn't quite what was asked. CTRL+F4 switches between windows in the current space, but the question was about switching between applications in the current space. I point this out because I have 2 terminal apps and 1 Emacs app open in a space, and I want to easily switch between the terminal windows and the Emacs app. Maybe I'll ask another question... – Jeff Terrell Ph.D. Dec 16 '13 at 15:51
  • 2
    This keyboard shortcut is no longer present in System Preferences as of Mavericks. – Cory Klein Apr 25 '14 at 17:58
  • 2
    i notice there's an issue unless you specifically click on the app window itself in the new space (if you switch to a new space and use the shortcut, it switches back to the previous space) – dtc Oct 18 '14 at 08:59
  • 1
    Aww, osx windows management is so f*d up. Why not just let users tick some setting if they want to swap between windows in space scope or global scope. Your solution works but for developers who has ctrl+' bind to functionality in IDEs its useless and considering you have to use stupid osx cmd+` to swap between windows of same app (which is UX nightmare), there is no other convenient keyboard shortcut to use for this. Otherwise brilliant UI is so messed up with so basic rookie UX mistakes from Apple. Very disappointed :( – Srneczek Sep 21 '16 at 11:28
  • If I press ctrl+f4 I have another window. However, if I press it again, it does not move back, rather moves to another window. Is there a way to make this behave the same as cmd + tab? – tsusanka Jul 19 '17 at 21:52
  • 1
    Fun fact, add shift to this key combination (or whatever you've remapped it to) and you can cycle through open windows in reverse order. Works just like cmd+tab does now @tsusanka . – Mark Thomson Jan 28 '19 at 04:29
  • 2
    This command has no preview – Fabrizio Bertoglio Jul 04 '19 at 05:34
36

Yosemite

This behavior can be mapped to your desired key combination like so:

System Preferences > Keyboard > Shortcuts > Keyboard > Move focus to active or next window

Mavericks

^F4 does switch through windows in the current space but you may have to upgrade to Yosemite to map this behavior to ^~.

But the problem can still be alleviated like so:

System Preferences > Mission Control > Uncheck "When switching to an application, switch to a Space with open windows for the application"

Cory Klein
  • 1,391
36

I found the open source app alt-tab-macos does exactly what OP wants: Providing an app switcher for apps on the current desktop only.

It also works well for full screen / minimized / hidden windows as well as across multiple display situations where Mission Control and macOS work more on spaces as opposed to separate displays.

bmike
  • 235,889
Cnly
  • 461
  • 10
    THIS IS FANTASTIC ANSWER. It should be the solution... I am not sure why peoples are saying that ctrl+f4 is user friendly... is NOT! I wanna rest both my hands almost all the time... – Dariusz Filipiak Mar 07 '21 at 15:54
  • 1
    Like it more then Hyperswitch (the last one ish't that stable and isn't opensourse) – GHopper Oct 27 '21 at 10:40
  • Forget all other options, this is the true answer! Far better than Hyperswitch - I've been using the Beta version (update never available), and it doesn't even compare to this one! Thank you! – Lucas Lima Mar 08 '22 at 16:14
  • 1
    This solution works supremely well for me in 2022 on Monterey and M1 machines and has very powerful UI / customization options like having the pointer / mouse follow the focus change to a new window. – bmike Mar 15 '22 at 22:21
  • I use the app religiously, but I don't think it solves this question. Once I open a new space on Mac, pressing alt+tab will still open all the windows that I had previously opened. Is there a setting on the app to enable a clean slate when I move to a new space? – Marko Mar 27 '22 at 14:12
  • Just a note: This app asks for screen and audio recording permission, and it's not optional. It doesn't work without it. – harmancode Apr 01 '23 at 01:17
14

I know Hyperswitch didn't exist when that question was asked, but it is a modern answer to that question, and it is much better than hacking with Karabiner (formerly KeyRemap4MacBook) and/or struggling with the system preferences (since they don't accept any key mapping for every command).

Please see https://apple.stackexchange.com/a/127414 and upvote it if you find HyperSwitch useful.

7heo.tk
  • 243
  • 2
    Hyperswitch solves exactly what @ESultanik was asking for. Cmd-Tab still is the traditional app switch (with the added screenshot of the app windows and in which spaces they are), plus alt-tab switches only between the apps within the current space – hansaplast Dec 04 '16 at 12:41
4

I'm the author of the Command-Tab Plus application which allows you to quickly switch between applications, and additionally between windows (using MacOS's cmd+tilde ability). Here's a demo on YouTube.

  • 1
    Unfortunately it is paid. :( – markroxor Jan 19 '19 at 05:41
  • 2
    Yes, it’s my job and I can’t give out coffee or applications for free ... by paying for applications you finance the further development of applications .... – Serge Gerasimenko Aug 30 '19 at 06:29
  • 1
    50$ for something free on ubuntu – Fabrizio Bertoglio Jan 24 '20 at 21:21
  • I just discovered Command-Tab Plus from this comment and I'm a very happy customer. It's only $15, and IMO worth it since I probably press Command-Tab 1000 times per day. – Aaron Iba Apr 23 '20 at 18:58
  • Thank you very much ... I will soon be developing a completely new version 2.0 – Serge Gerasimenko Apr 29 '20 at 05:33
  • 1
    Unfortunately I purchased this app... After roughly one year, the developer still hasn't fixed proper multi screen support... Luckily I got to know hammerspoon, which provides similar functionality using hs.window.switcher and is free + opensource. – Stefan Oct 05 '20 at 15:51
  • @Stefan Thanks for the criticism, in reality this is not a bug, but a feature ... due to the architecture of the application I cannot fix it, but I think in version 2.0 it will work fine – Serge Gerasimenko Oct 27 '20 at 09:02
3

As an aside to this answer, I've been able to remap control+F4 to alt+tab, which feels quite natural imo.

3

After trying many options I went for Contexts which costs 10$.

You can configure it so that cmd-tab shows only…

  • application of current space (see command-tab setting show windows from "visible spaces")
  • hide some windows ("background" apps such as VPN to which I don't need to switch to)

It organizes the icons in a list (vertically) instead of the default horizontal layout, which I needed to adapt to, but on the other side it also let's you search through all open apps with ctrl-space and there the list layout is beneficial.

2

One powerful tool is hammerspoon.

From its webpage:

This is a tool for powerful automation of OS X. At its core, Hammerspoon is just a bridge between the operating system and a Lua scripting engine. What gives Hammerspoon its power is a set of extensions that expose specific pieces of system functionality, to the user.

Using hs.window.switcher one just adds (as mentioned in the docs) to the init.lua

switcher_space = hs.window.switcher.new(hs.window.filter.new():setCurrentSpace(true):setDefaultFilter{})
hs.hotkey.bind('alt','tab','Next window',function()switcher_space:next()end)
hs.hotkey.bind('alt-shift','tab','Prev window',function()switcher_space:previous()end)

and one can happily switch between windows in the current space using alt+tab and alt+shift+tab.

If you like Lua scripting, you can extend the tool easily. Moreover, there are numerous plugins, called spoons, available. See also official hammerspoon spoons.

Stefan
  • 259
2

Pressing ⌃F4 will do what you're asking for, but you might get carpal tunnel in the process.

Just from reading your example, it sounds like you may actually be looking for ⌘⇧⇥, which cycles through applications in reverse order, thus cutting the number of times you press in half.

Granted, that's not be a constant time solution, but I think you'll find that the result of ⌘⇥ is the application you want to focus on 70% of the time, and ⌘⇧⇥ is the application you want to focus on 28% of the time.

Merchako
  • 1,106
  • 2
    For me, ⌘⇥ is right about 50% of the time, and the other 50% is about log(1.5)ly split between the other apps. – Sparr Jul 23 '12 at 16:51
  • Plus one for carpal tunnel :D I think Apple wants developers to get one... I bet they own shares in some medical industry company treating ergonomic diseases :) – Srneczek Sep 21 '16 at 11:31
0

Although this doesn't technically answer the original question, those here looking for a more configurable Cmd-Tab app switcher could look at SuperTab .

Disclaimer: I bought this and it think it's well done.

0

for those searching where that keyboard shortcut is located:

shortcut

I've mapped mine to option + tab

equivalent8
  • 101
  • 2
0

You can try with Switché. They pretend that "Switché works great with Spaces and is able to display Space number badges". As I'm not using Spaces I cannot confirm nor infirm but it's worth the try.
See comments below.

LudoMC
  • 3,961
  • 2
    Try it, but be aware switche has a really crappy demo. It has a popup asking you to buy every 3 or 4 times you switch windows. Drove me nuts in about 20 minutes and I uninstalled it. – Robert S Ciaccio Dec 29 '10 at 19:30
  • Switché shows all open apps. It does not do what the OP requests. –  Feb 01 '11 at 05:29
  • 1
    Hmm, I don't remember the numerous nag screens when I tested it some time ago. Doesn't deserve then to be publicized. I edited my answer. – LudoMC Feb 01 '11 at 21:46