简体   繁体   English

如何重置 Visual Studio Code 中的设置?

[英]How to reset settings in Visual Studio Code?

It's a simple thing and I was pretty sure it's well described, but surprisingly it is not so obvious.这是一件简单的事情,我很确定它描述得很好,但令人惊讶的是它并不那么明显。

Here I've found a detailed description of settings file. 在这里,我找到了设置文件的详细说明。 As it states it should be setting.json file located %APPDATA%\Code\User\settings.json , but in my case it's not there.正如它所说,它应该是setting.json文件位于%APPDATA%\Code\User\settings.json ,但在我的情况下它不存在。

Can someone give me some help with restoring default settings in Visual Studio Code?有人可以帮我恢复 Visual Studio Code 中的默认设置吗? I've hidden menu bar by accident and I can't find no way to show it back.我不小心隐藏了菜单栏,我找不到任何方法来显示它。

You can get your menu back by pressing/holding alt , you can then toggle the menu back on via the View menu.您可以通过按住alt来恢复菜单,然后可以通过 View 菜单重新打开菜单。

As for your settings, you can open your user settings through the command palette:至于您的设置,您可以通过命令面板打开您的用户设置:

  1. Press F1F1
  2. Type user settings键入user settings
  3. Press enter回车
  4. Click the "sheet" icon to open the settings.json file:单击“工作表”图标打开 settings.json 文件:

    在此处输入图像描述

From there you can delete the file's contents and save to reset your settings.从那里您可以删除文件的内容并保存以重置您的设置。


For a more manual route, the settings files are located in the following locations :对于更手动的路线,设置文件位于以下位置

  • Windows %APPDATA%\Code\User\settings.json Windows %APPDATA%\Code\User\settings.json
  • macOS $HOME/Library/Application Support/Code/User/settings.json macOS $HOME/Library/Application Support/Code/User/settings.json
  • Linux $HOME/.config/Code/User/settings.json Linux $HOME/.config/Code/User/settings.json

Extensions are located in the following locations :扩展位于以下位置

  • Windows %USERPROFILE%\.vscode\extensions Windows %USERPROFILE%\.vscode\extensions
  • macOS ~/.vscode/extensions macOS ~/.vscode/extensions
  • Linux ~/.vscode/extensions Linux ~/.vscode/extensions

If you want to reset everything, go to %userprofile%\AppData\Roaming\Code and delete the whole folder after you uninstall the VS code, then install it again.如果要重置所有内容,请在卸载 VS 代码后转到%userprofile%\AppData\Roaming\Code并删除整个文件夹,然后重新安装。

Also in %userprofile%\.vscode delete extensions folder in case you want to delete all extensions.同样在%userprofile%\.vscode删除扩展文件夹中,以防您想删除所有扩展。

This may be overkill, but it seemed to work for me (on a Mac):这可能有点矫枉过正,但它似乎对我有用(在 Mac 上):

#!/bin/sh

rm -rfv "$HOME/.vscode"
rm -rfv "$HOME/Library/Application Support/Code"
rm -rfv "$HOME/Library/Caches/com.microsoft.VSCode"
rm -rfv "$HOME/Library/Saved Application State/com.microsoft.VSCode.savedState"

After I ran that, and restarted VSC, it showed the the "Welcome" screen, which I took to mean that it was starting from scratch.在我运行它并重新启动 VSC 之后,它显示了“欢迎”屏幕,我认为这意味着它是从头开始的。

If you want to start afresh, deleting the settings.json file from your user's profile will do the trick.如果你想重新开始,从你的用户配置文件中删除settings.json文件就可以了。

But if you don't want to reset everything, it is still possible through settings menu.但是,如果您不想重置所有内容,仍然可以通过设置菜单进行。

设置菜单

You can search for the setting that you want to revert back using search box.您可以使用搜索框搜索要恢复的设置。

You will see some settings with the left blue line , it means you've modified that one.你会看到左边蓝线的一些设置,这意味着你已经修改了那个。

搜索设置

If you take your cursor to that setting, a gear button will appear.如果您将光标移至该设置,则会出现一个齿轮按钮。 You can click this to restore that setting.您可以单击它来恢复该设置。

齿轮按钮

You can also use the drop-down below that setting and change it to default.您还可以使用该设置下方的下拉菜单并将其更改为默认值。

设置下拉

在 Linux 环境中,删除文件夹“~/.config/Code”以重置 Visual Studio Code 设置。

You can reset both the user and workspace settings in VS Code as shown in the following screenshots您可以在VS Code中重置用户和工作区设置,如以下屏幕截图所示

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

  1. Go to Menu Bar .转到Menu Bar Click on File -> Preferences -> Settings单击File -> Preferences -> Settings 在此处输入图像描述
  2. On the top right corner of the Settings tab, click on the 3 dots button ... -> Show Modified SettingsSettings选项卡的右上角,单击 3 点按钮... -> Show Modified Settings 在此处输入图像描述
  3. You can now reset all the modified settings individually您现在可以单独重置所有修改的设置在此处输入图像描述

Steps to reset on Windows:在 Windows 上重置的步骤:

  • Press 'Windows-Key"+R , and enter %APPDATA%\Code\User按 'Windows-Key"+R ,然后输入 %APPDATA%\Code\User

    在此处输入图像描述

    And delete 'setting.json' at this location.并在此位置删除“setting.json”。

  • Press 'Windows-Key"+R , and enter %USERPROFILE%\.vscode\extensions按 'Windows-Key"+R ,然后输入 %USERPROFILE%\.vscode\extensions

    在此处输入图像描述

    And delete all the extensions there.并删除那里的所有扩展名。

EDIT编辑

After two vote downs added images to make it more clear :)经过两次投票后,添加了图像以使其更清晰:)

Go to File -> preferences -> settings.转到文件-> 首选项-> 设置。

On the right panel you will see all customized user settings so you can remove the ones you want to reset.在右侧面板上,您将看到所有自定义用户设置,因此您可以删除要重置的设置。 On doing so the default settings mentioned in left pane will become active instantly.这样做后,左窗格中提到的默认设置将立即生效。

The best easiest way I found to reset settings:我发现重置设置的最简单方法:

Open Settings page ( Ctrl + Shift + P ):打开设置页面( Ctrl + Shift + P ):

在此处输入图像描述

Go onto your desire setting section to reset, click on icon and then Reset Setting :转到您想要的设置部分进行重置,单击图标,然后单击重置设置

在此处输入图像描述

If all you want to do is "reset perspective" ala Eclipse (and why is this not in Code anyway?) then select [View] -> [Open View] -> [Run and Debug].如果您只想在 Eclipse 中“重置透视图”(为什么这不在 Code 中?)然后选择 [View] -> [Open View] -> [Run and Debug]。

This puts all the panes back, this is what most people mean by "reset perspective".这会将所有窗格放回原处,这就是大多数人所说的“重置透视图”。

注意,如果清除设置不能解决您的问题,您可能还需要卸载扩展程序。

If you just need to reset your profile for a quick test, VSCode 1.71 (Aug. 2022) will propose:如果您只需要重置您的个人资料以进行快速测试,VSCode 1.71(2022 年 8 月)将建议:

transient profiles瞬态轮廓

These profiles are deleted automatically once the last window which uses it is closed.一旦关闭使用它的最后一个 window,这些配置文件将自动删除。

You can create and associate a transient profile from您可以从以下位置创建和关联瞬态配置文件

  • CLI by passing --profile-transient flag. CLI 通过传递--profile-transient标志。 Eg:例如:

     code <folder-uri> --profile-transient
  • UI from Command Palette using command Create Transient Settings Profile使用命令Create Transient Settings Profile的命令面板中的 UI

These will create a transient settings profile and associate it to the workspace.这些将创建一个临时设置配置文件并将其与工作区相关联。
Once the workspace is closed (or uses different profile) this profile is deleted.一旦工作区关闭(或使用不同的配置文件),此配置文件将被删除。

That can help before going nuclear and deleting your current profile and VSCode settings .这可以在核化和删除您当前的配置文件和 VSCode 设置之前有所帮助。

This is released to VSCode Insiders today.这是今天向VSCode Insiders发布的。

To reset the default settings I'm not sure, but if you're just trying to get a menu bar back then try right clicking on the anywhere on the toolbar area and clicking the toolbar you need.要重置默认设置,我不确定,但如果您只是想恢复菜单栏,请尝试右键单击工具栏区域的任意位置,然后单击您需要的工具栏。

EDIT:编辑:
Figured out how to reset the settings Click on the tools button on the top, click "Import and Export Settings" and then click "Reset All Settings".弄清楚如何重置设置 单击顶部的工具按钮,单击“导入和导出设置”,然后单击“重置所有设置”。 Then go through the wizard from there.然后从那里通过向导。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM