Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>ContextKeyManagerNew to Visual Studio Code? Get it now.
ContextKeyManager

ContextKeyManager

Tejaromalius

| (0) | Free
Register, edit, toggle, and delete custom VS Code context keys for when clauses.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Context Key Manager

ContextKeyManager lets you register, edit, toggle, and delete custom VS Code context keys (usable in when clauses) directly from commands—no need to write a separate extension each time.

Features

  • Register: Context Keys: Register creates/overwrites a key & value.
  • Edit: Context Keys: Edit Value changes stored value/type.
  • Delete: Context Keys: Delete clears and removes a key.
  • Toggle: Context Keys: Toggle Boolean flips a boolean key (or auto-converts a non-boolean when invoked with an argument).
  • Auto re-hydration: previously stored keys restored on activation.

Supported Value Types

  • boolean (true / false)
  • string (raw text)
  • number (parsed with Number())
  • json (parsed using JSON.parse; falls back to string on parse failure)

Usage

  1. Command Palette (Ctrl+Shift+P) → run Context Keys: Register.
  2. Provide a name (recommend a prefix like user.) and value.
  3. Use the key in keybindings.json, menus, views: "when": "user.myMode == true".
  4. Toggle quickly:
{
  "key": "ctrl+alt+m",
  "command": "contextKeysManager.toggle",
  "args": "user.myMode"
}
  1. Edit or delete via the dedicated commands.

Example Keybinding

{
  "key": "ctrl+alt+k",
  "command": "workbench.action.findInFiles",
  "when": "user.myMode == true"
}

Programmatic Toggle

vscode.commands.executeCommand('contextKeysManager.toggle', 'user.myMode');

Development

cd extension
npm install
npm run compile

Launch with F5 to open an Extension Development Host.

Packaging

npm run package

Install the generated .vsix via: Command Palette → Extensions: Install from VSIX....

Persistence Notes

  • Keys stored in globalState; clearing VS Code state or using a different profile resets them.
  • Deleting a key sets its context value to undefined then removes it from storage.
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft