0

I want to configure a keyboard shortcut to rename a jsx tag only when a cursor is on an actual jsx tag.
Is there something that allows this?

source: https://code.visualstudio.com/api/references/when-clause-contexts#editor-when-clause-contexts


tl;dr

Currently CtrlF2 is mapped to changeAll, which is useful on its own, but in this case it results in ALL tags of the same name being targeted and renamed.

{ 
  "key": "ctrl+f2",
  "command": "editor.action.changeAll",
  "when": "editorTextFocus && !editorReadonly"
},

Therefore I want to use an extension that handles it per instance and be able to map it ideally to the same key and switch depending on cursor focus, like this:

{ 
  "key": "ctrl+f2",
  "command": "editor.emmet.action.updateTag",
  "when": "editorTextFocus && !editorReadonly && scope == 'entity.name.tag.tsx'"
},

This is the output of >Developer: Inspect Editor Tokens and Scopes command, where the scopes can be seen.

example screenshot from Token and Scopes inspector

Qwerty
  • 29,062
  • 22
  • 108
  • 136
  • I don't see anything like you're describing in [the when clause context reference page](https://code.visualstudio.com/api/references/when-clause-contexts), and don't find any promising search results googling `github vscode issues use textmate scope in "when clause"`. – starball Mar 13 '23 at 05:22

0 Answers0