114

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.

4
  • 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. 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. Dec 29 '10 at 20:31
  • 1
    (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

11 Answers 11

47

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.)

12
  • 7
    I think must use CTRL+fn+F4.
    – Am1rr3zA
    Feb 1 '11 at 8:04
  • 8
    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... 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 8:59
  • 2
    This command has no preview Jul 4 '19 at 5:34
33

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"

2
  • 1
    I have successfully remapped ^F4 to ^~ in Yosemite, so perhaps they fixed that bug?
    – Glyph
    Dec 9 '14 at 2:31
  • 1
    I successfully remapped to option+tab in Catalina
    – DB Prasad
    Nov 4 '19 at 3:30
13

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.

1
  • 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 4 '16 at 12:41
11

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.

1
  • 3
    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... Mar 7 at 15:54
3

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

1
  • 1
    this command does not show any preview as the original alt tab Jul 4 '19 at 5:28
3

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.

7
  • 1
    Unfortunately it is paid. :(
    – markroxor
    Jan 19 '19 at 5: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 .... Aug 30 '19 at 6:29
  • 1
    50$ for something free on ubuntu 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
  • 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 5 '20 at 15:51
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.

2
  • 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
1

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.

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.

3
  • 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. Dec 29 '10 at 19:30
  • Switché shows all open apps. It does not do what the OP requests.
    – user588
    Feb 1 '11 at 5:29
  • 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 1 '11 at 21:46
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

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .