2

VSCode by default binds cmd+p to workbench.action.quickOpen. Which is fine. My only issue is that when you confirm a quickOpen on a file using enter it opens the file in a “preview” mode (indicated by the tab’s name having an italic font). This “preview” mode means that if I open two files in a row using cmd+p the action of opening the second will take over the “preview” slot, effectively closing the first file's preview.

VSCode has a setting called workbench.editor.enablePreviewFromQuickOpen which you can use to change this behavior globally. But I don’t want to change it globally. You can also manually move a file out preview mode using workbench.action.keepEditor which is bound by default to cmd+k+enter. But that's an obnoxious extra step.

I would like to selectively decide when I want to open in “preview” mode or in “edit” mode. Ideally I would like to bind something like shift+enter to do this. In my keybindings.json have tried variations on

{
    "key": "shift+enter",
    "command": "workbench.action.keepEditor",
    "when": "inFilesPicker && inQuickOpen"
}

but with no luck :(

The answer to this question ALMOST does what I want: vscode: Open file instead of previewing file from quick open

The proposed solution of using alt+enter opens the file in a new window. No bueno.

The proposed solution of using the right arrow key to open the file does work... but it does not close the Command Palette like hitting enter does. No bueno.

jbccollins
  • 982
  • 1
  • 6
  • 19

1 Answers1

1

I do believe you will have to use a macro extension like multi-command. In your settings.json:

"multiCommand.commands": [
  {
    "command": "multiCommand.openFileNotInPreview",
    "sequence": [
      "workbench.action.acceptSelectedQuickOpenItem",
      "workbench.action.keepEditor",
    ]
  }
]

In keybindings.json some keybinding:

{
  "key": "shift+right",
  "command": "extension.multiCommand.execute",
  "args": { "command": "multiCommand.openFileNotInPreview" },
  "when": "inFilesPicker && inQuickOpen"
},

I used "shift+right" here, your "shift+enter" seemed to run into conflicts and would not work.

This will open your selected file in the Ctrl-P panel in a new editor in your same editor group and it will not be in preview mode.

Mark
  • 143,421
  • 24
  • 428
  • 436