Programming

How to disable preview file with single-click in vs code

19 September 2026 · 9 min read

How to disable preview file with single-click in vs code

Visual Studio Code (VS Code) is a powerful and versatile code editor favored by developers worldwide for its extensive features and customization options. One feature that can sometimes be a source of frustration is the preview file behavior triggered by a single click. This “single-click preview,” while intended to provide a quick glance at a file’s contents, can disrupt workflow by rapidly opening and closing tabs as you navigate your project. Many users find themselves wanting to disable preview file with single-click in VS Code to achieve a more deliberate and controlled editing experience. Learning how to configure this setting allows you to tailor VS Code to better suit your individual coding style, improving productivity and reducing unwanted distractions.

Understanding the Preview Editor in VS Code

The preview editor, also known as the “peek” editor, is designed to offer a temporary view of a file. When you single-click a file in the Explorer panel, VS Code opens it in a preview tab. This tab is marked with an italicized title, indicating that it’s not a fully opened editor. If you then click another file, the preview tab will be replaced with the content of the new file. This behavior aims to allow for quick inspections without cluttering the editor with numerous open tabs. However, for developers who prefer a more traditional double-click-to-open approach, this can become disruptive, especially when browsing through large projects or quickly scanning multiple files. The single-click preview feature can lead to accidentally overwriting the preview with the wrong file, forcing you to re-navigate to the file you actually wanted to edit.

The concept behind the preview editor is efficient context switching. It allows you to quickly view the contents of a file without committing to opening it fully. Think of it as a “quick look” feature for your code. It’s particularly useful when you need to verify something quickly or compare small snippets of code across different files. However, the default single-click behavior can be jarring for those accustomed to double-clicking to open files. Understanding the purpose of the preview editor helps in deciding whether to disable it or adjust its behavior to better fit your workflow. Disabling the preview editor effectively makes VS Code behave more like a traditional text editor where a double-click is required to fully open a file for editing.

According to a Stack Overflow survey, a significant percentage of developers customize their VS Code settings to optimize their workflow. This includes adjusting editor behaviors like the preview editor. Learning to control these settings is a crucial aspect of becoming a proficient VS Code user. Customization is key to maximizing productivity and minimizing frustration. One of the most important aspects of customization is being able to disable preview file with single-click in VS Code.

Methods to Disable Single-Click Preview

There are several ways to disable preview file with single-click in VS Code, giving you flexibility in choosing the method that best suits your preferences. The most common approach involves modifying VS Code’s settings directly. This can be done through the graphical user interface (GUI) or by editing the settings.json file. Another method involves using extensions that can manage editor behaviors, providing a more streamlined way to customize VS Code’s functionality. Regardless of the method you choose, the end goal is to prevent files from opening in preview mode when you single-click them in the Explorer.

Here’s how to disable the single-click preview using the settings GUI:

  1. Open VS Code.
  2. Go to File > Preferences > Settings (or use the shortcut Ctrl+, on Windows/Linux or Cmd+, on macOS).
  3. In the Settings search bar, type “enable preview”.
  4. You will see two settings: “Workbench: Enable Preview” and “Workbench: Enable Preview From Code”.
  5. Uncheck both of these boxes.

By unchecking these boxes, you effectively tell VS Code to only open files fully when you double-click them, thus disabling the single-click preview behavior. This will require a restart of the VS Code application.

Modifying settings.json for Advanced Control

For those who prefer a more hands-on approach, editing the settings.json file directly offers finer-grained control over VS Code’s behavior. This method involves opening the settings file and adding or modifying specific JSON entries to disable preview file with single-click in VS Code. While it requires a bit more technical knowledge, it allows for more precise customization and can be easily shared across different VS Code installations or team environments. Modifying settings.json is especially useful for those who frequently switch between different VS Code configurations or want to automate the setup process.

To modify the settings.json file, follow these steps:

  1. Open VS Code.
  2. Go to File > Preferences > Settings (or use the shortcut Ctrl+, on Windows/Linux or Cmd+, on macOS).
  3. Click on the “Open Settings (JSON)” icon in the top-right corner of the Settings editor.
  4. This will open the settings.json file. Add the following lines within the curly braces: ``` “workbench.editor.enablePreview”: false, “workbench.editor.enablePreviewFromCode”: false
  5. Save the file.

Adding these lines to your settings.json file will effectively disable the single-click preview. VS Code will automatically detect the changes and apply them without requiring a restart. This method is particularly useful when you want to enforce a specific configuration across your development environment. It also allows you to easily revert back to the default behavior by simply removing these lines from the settings.json file. Using the settings.json file also allows for a more programmatic approach to configuring VS Code, making it easier to manage settings across multiple machines or team members. This can be beneficial for maintaining consistency and ensuring that everyone is working with the same development environment.

Benefits of Disabling Preview File with Single-Click

Disabling the single-click preview offers several advantages, particularly for developers who prioritize a deliberate and focused workflow. One of the primary benefits is reduced accidental tab switching. By requiring a double-click to fully open a file, you minimize the risk of inadvertently overwriting the preview tab with the wrong file. This can save time and prevent frustration, especially when working with complex projects or navigating through numerous files. Another benefit is improved tab management. With the single-click preview disabled, you have more control over which files are actually opened as full-fledged tabs, leading to a cleaner and more organized editor window. You can visit this page for more tips on productivity.

Here are some key benefits:

  • Reduces accidental tab switching and overwriting.
  • Improves tab management and organization.
  • Enhances focus and reduces distractions.

Furthermore, disabling the single-click preview can enhance focus and reduce distractions. By eliminating the rapid opening and closing of preview tabs, you can maintain a more consistent and predictable editing environment. This can be particularly beneficial for developers who are easily distracted or who prefer a more deliberate and methodical approach to coding. According to a study by the University of California, Irvine, interruptions can significantly decrease productivity and increase stress levels. By minimizing unnecessary interruptions caused by the single-click preview, you can create a more conducive environment for focused work.

Here is a featured snippet paragraph about the benefits: Disabling the single-click preview in VS Code offers several key benefits. It reduces accidental tab switching, preventing the preview tab from being overwritten with unintended files. This enhances tab management, providing a cleaner and more organized editor window. Ultimately, disabling the single-click preview improves focus and reduces distractions, creating a more efficient coding environment.

Alternative Solutions and Extensions

While disabling the single-click preview is a common solution, some developers might prefer alternative approaches or extensions that offer more granular control over the editor’s behavior. Several VS Code extensions can help manage tabs and editor groups, providing features like pinning tabs, automatically closing inactive tabs, or grouping related files together. These extensions can offer a more flexible way to manage your workspace without completely disabling the preview feature. Additionally, some developers might find that adjusting the settings related to tab behavior, such as the number of visible tabs or the way tabs are grouped, can also improve their workflow. One example can be found on VS Code Marketplace.

Here are some alternative solutions:

  • Use extensions for tab management (e.g., Tabnine, Material Icon Theme).
  • Adjust settings related to tab behavior (e.g., workbench.editor.tabSizing).
  • Explore keyboard shortcuts for navigating between files.

For example, the “Tabnine” extension offers intelligent code completion and can help you navigate through your code more efficiently, reducing the need to constantly switch between files. The VS Code documentation also provides valuable insights into customizing the user interface and optimizing your workflow. Exploring these alternative solutions can help you find the perfect balance between quick file access and a controlled editing environment. Remember that the best approach is the one that best fits your individual coding style and preferences.

Infographic here
FAQ About Disabling Preview File with Single-Click --------------------------------------------------
Why is the single-click preview enabled by default in VS Code?
The single-click preview is enabled by default to provide a quick and easy way to view file contents without fully opening them as tabs. It's intended to streamline the process of browsing through files and quickly verifying information.
Will disabling the single-click preview affect other VS Code features?
Disabling the single-click preview primarily affects how files are opened in the editor. It should not significantly impact other VS Code features or extensions. However, it might change the behavior of certain extensions that rely on the preview editor.
Can I re-enable the single-click preview if I change my mind?
Yes, you can easily re-enable the single-click preview by checking the "Workbench: Enable Preview" and "Workbench: Enable Preview From Code" boxes in the Settings or by removing the corresponding lines from your settings.json file.
Are there any keyboard shortcuts to quickly open a file without using the mouse?
Yes, VS Code offers several keyboard shortcuts for navigating and opening files. For example, Ctrl+P (Windows/Linux) or Cmd+P (macOS) opens the Go to File dialog, allowing you to quickly search and open files by name. You can also use Ctrl+Tab to cycle through open tabs.
Is there a way to disable the preview for only certain file types?
While there isn't a built-in setting to disable the preview for specific file types, you might be able to achieve this using extensions or by configuring custom file associations in your settings.json file. This would require more advanced configuration and might not be a straightforward solution.
It's all about creating a workspace that supports your personal workflow. By taking the time to understand and adjust settings like the single-click preview, you can significantly enhance your coding experience in VS Code. Experiment with different configurations and extensions to discover what works best for you. Consider exploring other customization options, such as themes, keybindings, and snippets, to further personalize your development environment. This will help you to be more efficient and effective, leading to better code and a more enjoyable development process. Check out more resources on [FreeCodeCamp](https://www.freecodecamp.org/news/vscode-tips/) for additional tips and resources. **Question & Answer :** I would much rather double-click to open file, and prevent single-click previews. How do we do that in vs code?

From vscode 1.20:

"workbench.list.openMode": "doubleClick",