visual-studio-codevscode-keybinding

What is the shortcut string representation of the move to file refactor in VS Code?


Refactor actions can be bound to shortcuts like seen in https://code.visualstudio.com/docs/editor/refactoring

{
  "key": "shift+ctrl+e",
  "command": "editor.action.codeAction",
  "args": {
    "kind": "refactor.extract.constant",
    "preferred": true,
    "apply": "ifSingle"
  }
}

I'd like to bind my F2 to move a symbol to a file (As in WebStorm). What "kind" value should I use?


Solution

  • If you're talking about the code action that the builtin TypeScript/JavaScript language support extension provides, then from searching ['"]refactor\..*move in https://github.dev/microsoft/vscode with regex search mode, I'm pretty confident you're looking for refactor.move.newFile, which is defined in the actions property in its package manifest, and in English, its title is localized to "Move to a new file", and its description to "Move the expression to a new file.".