239

I would much rather double-click to open file, and prevent single-click previews. How do we do that in vs code?

2
  • 39
    You can turn off preview by setting "workbench.editor.enablePreview": false, but you could not prevent single-click, which means single-click will open file for editing directly rather than preview.
    – Takahiro
    Commented Oct 31, 2016 at 5:11
  • 1
    You can convert a preview to a true editor with workbench.action.keepeditor which is ⌘K, Enter by default (being buried it's a Sublime Text throwback) Commented Mar 6, 2019 at 17:42

10 Answers 10

248

From vscode 1.20:

"workbench.list.openMode": "doubleClick",
5
  • 12
    I had to fight through a barrage of people answering the wrong question (funnily enough trying to disable preview mode by enabling a more permanent mode actually makes the issue more annoying!) to get to this, thank you @Alex
    – jmcgrory
    Commented Dec 11, 2019 at 10:15
  • I had the exact problem of @jmcgrory, this shoul be marked as solution
    – Ares9323
    Commented Mar 26, 2020 at 19:32
  • 3
    This is wrong. The preview function remains working.
    – JNAK
    Commented Apr 19, 2020 at 3:58
  • I upvoted the above comment, but then discovered that after a VS Code reset it worked! Commented Jan 28, 2022 at 17:01
  • 3
    It's been 3 years and I've just come back from the same issue on a new machine, tried the first (wrong) answer then looked further down and seen that I've not only upvoted but commented. Those that repeat history @Ares9323 ...
    – jmcgrory
    Commented Nov 14, 2022 at 21:54
148

The only way to disable file previewing when clicked on at all is by setting "workbench.editor.enablePreview" to false.

"workbench.editor.enablePreview": false,

enter image description here

6
  • 3
    This does NOT change the behaviour, that the file only gets opened in a tab when double clicked. The only difference is, that it gets opened in "edit mode" rather than in "preview mode".
    – phifi
    Commented Nov 17, 2017 at 10:14
  • 3
    That's how you disable file previewing and open the file. VS Code can't do the double click thing. Commented Nov 22, 2017 at 19:37
  • 2
    @MichaelJ.Calkins has the correct answer to this issue. This should be marked as correct.
    – Armin
    Commented May 1, 2019 at 20:10
  • 3
    this is for older version, please look at the top answer
    – Yuki
    Commented Jun 22, 2019 at 16:05
  • 1
    Thank you I was looking for this one :)
    – Pravin W
    Commented Feb 9, 2022 at 15:15
83

Go to File->Preferences->Settings, search for the following and disable it:

"workbench.editor.enablePreview": false

Italian Trulli

2
  • 5
    Making this change will cause single-clicks to open (rather than preview) files. If you want to disable all single-click actions, use Alex's suggestion.
    – Tony
    Commented Dec 23, 2019 at 12:50
  • This is the wrong answer. This will open the files on single click. OP and myself wants to disable single click preview and single click file opens. It should be single click selects the file and double click opens it. The issue is that clicking a file in the explorer window opens a preview causing you to lose focus on the document that you want to keep open. Your suggestion to remove previews actually causes automatic file opening, which is a worse disruptive behaviour.
    – JNAK
    Commented Apr 19, 2020 at 3:57
39

The necessary settings to prevent single-click in the Explorer view opening a file at all are in the previous answers to this question but you need to apply two of them:

"workbench.editor.enablePreview": false

That will change single-click in the explorer to fully open the file instead of opening it in preview (italics) mode. Arguably this is worse than before unless you're on a touchscreen device so you also need the following setting:

"workbench.list.openMode": "doubleClick"

Now you have to double-click on a file in Explorer to open it and preview is off. Finally, I had to restart all open instances of vscode for the doubleClick change to take effect.

vscode is a moving target so I should point out this was tested in version 1.45.1.

0
11

Probably you're mixing the terms. I guess you are talking about "Peek" feature:

vscode peek

And here is how you can disable it:

"editor.gotoLocation.multipleDefinitions": "goto"


Also, there is a "Preview editor" feature:

vscode preview editor

That could be disabled by:

"workbench.editor.enablePreview": false

1
  • 1
    for me, definitely what I was looking for - thank you Commented Apr 20, 2022 at 0:12
8

As far as I know there is no way to do this right now (version 1.12).

Many people "requested" this feature, just look at this GitHub issue.

.. and a relatively new comment about the issue:

Sorry, didn't have much time to look into this again. As it stands right now we need to clean up some debt first in the area of tree usage throughout our code before we can ask for a PR again.

3
  • 3
    That behaviour really annoys me - thanks for the link to the issue though.
    – phifi
    Commented Nov 17, 2017 at 10:16
  • Thanks for the link, the issue was closed. 3 year later this issue is still not resolved.
    – JNAK
    Commented Apr 19, 2020 at 3:59
  • Look at the openMode option! Commented Apr 20, 2020 at 5:12
5

Here is how to set this from UI level if you do not want to edit files directly: File -> Preferences -> Workbench -> List: Open mode = 'doubleClick'

or

File -> Preferences -> search for 'Open mode' and set it to 'doubleClick'

5

So I had to do both suggestions by @Alex and @MichaelJ.Calkins. More specifically I had to configure the open mode setting to click and enable preview to true. That way I can preview with a single click and actually keep it open with a double click. Below are the settings that were configured.

"workbench.list.openMode": "singleClick",

"workbench.editor.enablePreview": true,
1
  • 4
    This is exactly how I wanted it. Thanks
    – Joel H
    Commented Dec 26, 2019 at 9:59
4

Another configuration entry (above the "workbench.editor.enablePreview": true) that can prevent VSCode from opening files on new tab is the following:

"workbench.editor.showTabs": false

Make sure it is removed from settings.json or it is set to true.

1
  • Thanks for this, The 'preview' feature is garbage according to me. Commented Sep 18, 2023 at 15:38
4

Go to visual studio code settings on the bottom left and then search for 'preview' settings. Make sure that 'enable preview' is not enabled in 'WorkBench > Editor'

visual studio code settings

Not the answer you're looking for? Browse other questions tagged or ask your own question.