59

If I quick open a file using the quick open menu, is there a keyboard shortcut that will take the opened file outside of preview mode so that when I open a new file it won't replace the currently open one?

(I'm looking for a keyboard shortcut as opposed to double-clicking the filename or tab in order to keep my workflow keyboard oriented)

Gama11
  • 31,714
  • 9
  • 78
  • 100
M.K. Safi
  • 6,560
  • 10
  • 40
  • 58
  • 2
    Note that after hitting control-p (Quick Open), you can hit the right arrow key instead of enter to make a file open not-in-preview-mode. Although then you have to hit escape to close the list of files (I wish there was a way to avoid that). – KevinVictor May 20 '20 at 14:51

3 Answers3

84

Try the View: Keep Editor command (default shortcut Ctrl+K, Enter):

Note: this shortcut is a chord, meaning that Enter must be pressed after releasing Ctrl+K.

Gama11
  • 31,714
  • 9
  • 78
  • 100
23

As of v1.19 (released in December 2017) Alt+Enter opens the file (after Ctrl+P) NOT in preview mode but in a "permanent", touched status.

Related question: How do I configure Visual Studio Code to open files always in a new tab?

Gama11
  • 31,714
  • 9
  • 78
  • 100
Mark
  • 143,421
  • 24
  • 428
  • 436
  • 2
    Alternatively, you can also use press Right Arrow key, while the name of the file is highlighted. – ludovico Aug 18 '19 at 22:19
  • For me, using Alt+Enter opens the file in side-by-side mode instead of creating a new tab. Using the Right Arrow key almost works but I have to hit Escape to close the list of files. Do you know any way to skip that extra keystroke? – KevinVictor May 20 '20 at 15:01
  • **For anyone using the Vimium plugin:** the accepted answer collides with vim's keystrokes, but this answer works perfectly for me. – 0p3r4t0r Oct 22 '20 at 01:14
19

If you would rather open the file directly from Quick Open (skipping the preview mode altogether), you can change this in the settings or add this to settings.json:

"workbench.editor.enablePreviewFromQuickOpen": false

If you want to disable previews for other means of opening files (like the project explorer), this will do the trick:

"workbench.editor.enablePreview": false
Gama11
  • 31,714
  • 9
  • 78
  • 100
Patrick
  • 1,227
  • 14
  • 17
  • This isn't working for me on macOS Catalina with the latest VS Code. Posted an issue here: https://github.com/microsoft/vscode/issues/110952. Using Alt+Enter to open from CMD+P (in answer from Mark above, was the most elegant solution to this problem, IMO) – Kraken Nov 19 '20 at 15:24