Pro Q
Pro Q

Reputation: 5038

How to add "a" shortcut to VSCode for creating a file

I used to use Atom where I could select a folder in the explorer sidebar, press "a", and then this would create a new file.

I thought I had finally gotten this command to work in VSCode by

  1. Setting up the keyboard shortcut for File: New File to be A with a When of sideBarFocus
  2. Disabling file filtering

This configuration allows me to create a new file by pressing "a".

However, if I try to rename a file to contain the letter "a", I cannot, because as soon as I press "a" it tries to create a new file.

I would like to be able to name files to contain the letter "a". (While having "a" still allow me to create a new file when I'm not renaming.)

How can I fix this?

Upvotes: 1

Views: 448

Answers (1)

Mark
Mark

Reputation: 182441

Add another negated when clause to your keybinding:

    {
        "key": "a",
        "command": "explorer.newFile",
        "when": "sideBarFocus && !inputFocus"
    }

so it won't operate when an input box has focus.

Upvotes: 1

Related Questions