Quick window switching for VS Code on macOS.
In contrast with the Switch Window... shortcut (workbench.action.switchWindow
) or the standard macOS shortcut Cmd-`
, the orders of the windows will be updated and recalled (similar to the "View: Quick Open Previous Recently Used Editor in Group" command but for windows) so switching between a few windows (out of all the VS Code windows) becomes easier.
This project consists of two main components:
- Swift Helper Process (
swift-helper/
): A background macOS executable that handles window management using Accessibility APIs - VS Code Extension (
vscode-extension/
): The user-facing extension that provides UI and commands
The Swift Helper Process is the one doing the window switching. It handles the gathering of the VS Code window titles using the macOS Accessibility API.
- macOS 12.0 or later
- Xcode Command Line Tools (for Swift compilation)
- Node.js 18+ (for VS Code extension development)
- VS Code 1.80.0 or later
There is no distribution on the VS Code Extension marketplace so the extension will have to be built.
The Swift helper is a background process that manages VS Code windows using macOS Accessibility APIs.
cd swift-helper
./package.sh
This creates a Backtick++ Helper.app
bundle that can be distributed. It simply contains a command-line executable (so cannot be launched manually, but will be launched by the VS Code extension).
Copy the .app
in /Applications
(this is the default name and will be found by the VS Code extension). Or use the backtick-plus-plus.helperAppPath
VS Code setting to point at the executable Contents/MacOS/backtick-plus-plus-helper
inside the .app
anywhere.
cd vscode-extension
npm install
cd vscode-extension
npx vsce package
This creates a .vsix
file that can be installed in VS Code: In the Extensions view, click the ellipsis (...) and select "Install from VSIX...".
backtick-plus-plus.switchForward
(by defaultcmd+alt+shift+f
) - Switch forward through windowsbacktick-plus-plus.switchBackward
(by defaultcmd+alt+shift+g
) - Switch backward through windowsbacktick-plus-plus.instantSwitch
(by defaultcmd+alt+shift+d
) - Instant switch to second window (to switch between 2 windows quickly)
The Switch forward and Switch backward can be pressed multiple times while the quick pick listbox is open in VS Code.
However, Enter must be pressed to select the window to switch to: This differs from the "View: Quick Open Previous Recently Used Editor in Group", usually Ctrl-Tab, where an editor is selected when Ctrl is let go (that behaviour doesn't seem to be available for extensions).
Escape or focusing outside the listbox will dismiss the quick pick.
The extension provides these settings:
-
backtick-plus-plus.activationMode
: How window activation is handled (if done outside the extension)automatic
(default): Current window moves to top of listmanual
: Preserves current window order
-
backtick-plus-plus.newWindowPosition
: Where new windows appeartop
(default): New windows at top of listbottom
: New windows at bottom of list
-
backtick-plus-plus.helperAppPath
: Full path to the executable of the Backtick++ Helper (usually inside an.app
)
- The extension will automatically start the helper process
- You'll be prompted to grant Accessibility permissions (used by the Backtick++ Helper to gather the titles of all the VS Code windows)
- Click "Request Permission" and approve in System Preferences. VS Code will be the application requesting that permission since it is launching the Helper.
- Reload VS Code window when prompted
The logs are available after the extension has launched in a VS Code window in the Output panel, Backtick++ entry in the listbox on the right.
The simplest is to use the Swift VS Code extension and launch the executable in debug mode.
Manually:
cd swift-helper
swift build -c debug
.build/debug/backtick-plus-plus-helpers
The helper uses os.log
for logging. View logs with:
log stream --predicate 'subsystem == "com.backtickpp.helper"'
# Test if helper is running
nc -U /tmp/backtick-plus-plus-helper.sock
# Send test commands
echo "getStatus" | nc -U /tmp/backtick-plus-plus-helper.sock
- Create a task that run
npm run compile
and called Extension: Compile TypeScript (used by 2.) - Create an
extensionHost
launch configuration. Set the path since the code for the extension is not at the root of the project. For example:
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}/vscode-extension"
],
"preLaunchTask": "Extension: Compile TypeScript"
}
- Launch the Backtick++ Helper manually (in dev mode, it is not launched by the extension)
- Press
F5
to launch Extension Development Host - The extension will be loaded in the new VS Code window
- Use
console.log()
in your TypeScript code - View output in the Debug Console of the main VS Code window
cd vscode-extension
npm run watch
After making changes, reload the Extension Development Host window (Cmd+R
).