tmp dev
tmp dev

Reputation: 9219

Visual Studio Code, open file shortcut for double click

I am using the Ctrl+, keyboard shortcut to navigate between files. However when I select a file and press Enter it opens file in the existing tab with italics on the title. If I select another file using Ctrl+, and press enter it opens the other file on the same tab. Is there a keyboard shortcut to open the file in a new tab instead of the same tab?

Upvotes: 25

Views: 25205

Answers (4)

phil294
phil294

Reputation: 10892

What if I want to make that file not in preview mode without changing that setting? What is the shortcut for that?

  • You can press ctrlS, aka the save command. There is nothing to save, but it does what you require.

This can trigger reload actions in some development file servers, however. There are two more ways that I found, slightly more laborious:

  • ctrlW, ctrlshiftT: Close tab, reopen tab. No more in preview state. But this will make you lose your undo history for the file. (Edit in 2020: Not anymore, as undo history is now preserved even after file close. But of course some plugin logic might be affected by it)
  • ctrlshiftPgUp(, ctrlshiftPgDown): Move the tab one to the left and optionally back to the right again. Not sure if these keybindings are the default ones, but you get the idea.
  • Type something and undo
  • Move the tab into another editor group (and optionally back again). Example: View: Move Editor into Right Group, then View: Move Editor into Left Group. You could even make this a macro and assign it to a custom shortcut.
  • View: Pin Editor, View: Unpin Editor. Has the side effect of moving the tab to the very left
  • any more..?

Upvotes: 14

Daan Timmer
Daan Timmer

Reputation: 15057

The (default?) shortcut for the command that you want (That is the Keep open/View: Keep Editor command) is CTRL+K Enter

To see your shortcut open the command panel (CTRL+(shift)+P by default) and type the following command: >View: Keep Editor

enter image description here

You can also right-click the editor tab and near the bottom there should be the command Keep Open with the (default) shortcut next to it.

enter image description here

These commands allow you to 'keep the current tab open when navigating to a new file'. Doesn't match your requirement for the full 100% but for me it works wonders :-)

Upvotes: 2

H.Ibrahim
H.Ibrahim

Reputation: 439

"workbench.list.openMode": "doubleClick"

Upvotes: 43

John Topley
John Topley

Reputation: 115402

As you have seen, when you single-click a file it previews it in the current tab and you have to double-click it to open it properly for editing. You can disable this behaviour by going into Code's settings and specifying:

"workbench.editor.enablePreview": false

...in your user settings.

Upvotes: 27

Related Questions