MacOS – Restricting Command+tab options to only apps that are in the current space

macosspaces

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.

Best Answer

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