Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>IDE DetectorNew to Visual Studio Code? Get it now.
IDE Detector

IDE Detector

Kazuma Ito

|
4 installs
| (0) | Free
Automatically detects which IDE is running and sets corresponding context keys for conditional extension behavior, keybindings, and UI customization
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

IDE Detector

A VSCode extension that automatically detects which IDE is running and sets corresponding context keys. This allows you to customize your extension behavior, keybindings, and UI based on the specific IDE environment.

Table of Contents

  • Features
  • Supported IDEs
  • Installation
  • Usage
  • Configuration
  • How It Works
  • License

Features

  • 🎯 Automatic Detection: Detects the IDE on startup without any configuration
  • 🔑 Context Keys: Sets context keys that can be used in when clauses
  • ⚙️ Customizable: Configure custom IDE names and detection patterns
  • 🚀 Lightweight: Minimal overhead, activates on startup

Supported IDEs

The extension comes with default configurations for these IDEs (all customizable via settings):

  • Visual Studio Code: isVSCode
  • Cursor: isCursor
  • Antigravity: isAntigravity
  • Windsurf: isWindsurf

Note: These are default configurations. You can customize or add more IDEs through the Configuration settings.

Installation

  1. Open VSCode (or compatible IDE)
  2. Go to the Extensions view
  3. Search for "IDE Detector"
  4. Click Install

Or install from the command line:

code --install-extension kazuito.ide-detector

Usage

Once installed, the extension automatically detects your IDE and sets the appropriate context key on startup. You can use these context keys in some places:

In Keybindings (keybindings.json)

Create IDE-specific keybindings:

[
  {
    "key": "cmd+k cmd+c",
    "command": "workbench.action.showCommands",
    "when": "isCursor"
  },
  {
    "key": "cmd+shift+p",
    "command": "workbench.action.showCommands",
    "when": "isVSCode"
  }
]

In package.json (for extension development)

Use context keys in when clauses to conditionally enable features:

{
  "contributes": {
    "commands": [
      {
        "command": "myExtension.specialCommand",
        "title": "Special Command",
        "when": "isCursor"
      }
    ],
    "menus": {
      "editor/context": [
        {
          "command": "myExtension.vscodeOnly",
          "when": "isVSCode"
        }
      ]
    }
  }
}

Configuration

You can customize IDE detection by configuring the ide-detector.apps setting. This allows you to:

  • Add support for additional IDEs
  • Customize detection patterns using regex
  • Override default IDE configurations

Basic Configuration

Open your VSCode settings and add the configuration. You can set it in:

  • User Settings: Applies to all workspaces (File → Preferences → Settings → search for "ide-detector")
  • Workspace Settings: Applies only to the current workspace (.vscode/settings.json)

Add the following:

{
  "ide-detector.apps": [
    {
      "name": "MyCustomIDE",
      "matcher": "MyCustomIDE"
    },
    {
      "name": "VSCode",
      "matcher": "Visual Studio Code"
    }
  ]
}

Configuration Properties

  • name (required): The name of the IDE. This will be used to create the context key is{Name} (e.g., name: "Cursor" creates isCursor).
  • matcher (required): A regex pattern (as a string) that will be matched against the executable path. The pattern is converted to a regular expression.

Reserved Context Keys

⚠️ Important: Some context keys are reserved by VSCode and cannot be used. If you configure an IDE name that would create a reserved context key, the extension will show a warning and skip setting that context key.

Reserved context keys include (but are not limited to):

  • isLinux, isMac, isWindows, isWeb, isMobile, isIOS
  • isFullscreen, isWorkspaceTrusted, isWorkspaceTrustEnabled
  • isMergeEditor, isMergeResultEditor, isEmbeddedDiffEditor
  • isSettingsPaneOpen, isSettingsPaneFocused
  • And many others used by VSCode internally

Example: If you set name: "Linux", the extension would try to create isLinux, which is reserved. You'll see a warning and the context key won't be set.

To avoid conflicts, choose IDE names that don't conflict with VSCode's built-in context keys. The extension automatically detects and prevents setting reserved keys.

Regex Pattern Examples

{
  "ide-detector.apps": [
    {
      "name": "VSCodeInsiders",
      "matcher": "Code - Insiders"
    },
    {
      "name": "MyIDE",
      "matcher": "MyIDE.*\\.exe$"
    },
    {
      "name": "CustomEditor",
      "matcher": "Custom.*Editor"
    }
  ]
}

The matcher is converted to a regular expression, so you can use full regex syntax. The pattern is tested against process.execPath.

Settings Change Behavior

When you modify the ide-detector.apps setting, the extension automatically:

  • Re-detects the current IDE
  • Updates all context keys accordingly
  • Shows warnings for any reserved context keys

No restart required - changes take effect immediately!

How It Works

  1. Detection: On startup, the extension examines the executable path (process.execPath) of the running IDE.
  2. Matching: It matches this path against the configured regex patterns in ide-detector.apps.
  3. Context Setting: For each configured IDE, it sets the context key is{Name}:
    • true for the detected IDE
    • false for all other configured IDEs
  4. Dynamic Updates: When settings change, the extension automatically re-detects and updates all context keys.

Example: If you're running Cursor, the extension sets isCursor = true and isVSCode = false, isAntigravity = false, etc.

Note: If no IDE matches any configured pattern, all context keys are set to false.

Troubleshooting

Context keys are not being set

  1. Check the Output panel: Open View → Output, select "IDE Detector" from the dropdown to see any error messages.
  2. Verify your configuration: Ensure your ide-detector.apps setting is valid JSON and each entry has both name and matcher fields.
  3. Check for reserved keys: If you see a warning about reserved context keys, choose a different IDE name.
  4. Verify regex patterns: Test your regex patterns match the executable path. You can check process.execPath in the Developer Console (Help → Toggle Developer Tools).

Invalid regex pattern error

If you see an error about invalid regex patterns:

  • Ensure your matcher strings are valid regex patterns
  • Escape special characters properly (e.g., use \\. for a literal dot)
  • Test your patterns in a regex tester before adding them

IDE not detected

  • Check that your matcher pattern correctly matches your IDE's executable path
  • Use more flexible patterns if needed (e.g., .*Cursor.* instead of exact matches)
  • Check the executable path format on your operating system (Windows uses \, Unix uses /)

License

MIT - see LICENSE file for details

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft