vscode 清理缓存:Clearing the Visual Studio Code cache on Linux

Clearing the Visual Studio Code cache on Linux  How to clear the Cache in Visual Studio Code | bobbyhadz

  https://stackoverflow.com/questions/39234428/how-do-you-clear-your-visual-studio-code-cache-on-a-mac-linux-machine 

  https://tooabstractive.com/how-to-tech/how-to-delete-vscode-cached-data-files/ 

  Clearing the Cache in Visual Studio Code - DEV Community 

 ------------------------------------------------------------

关联参考:

vscode 清理缓存:Clearing the Visual Studio Code cache on Linux  https://blog.csdn.net/ken2232/article/details/144359505 

vscode 恢复默认设置:How to Reset Visual Studio Code to the Default Settings  https://blog.csdn.net/ken2232/article/details/144359394 

==================================

How to clear the Cache in Visual Studio Code

  > https://bobbyhadz.com/blog/vscode-clear-cache#clearing-the-visual-studio-code-cache-on-linux   

Borislav Hadzhiev

Last updated: Apr 6, 2024
Reading time·5 min

# Table of Contents

  1. Clearing VS Code editor history
  2. Clearing VS Code search history
  3. Clearing the Cache in Visual Studio Code
  4. Clearing the Visual Studio Code cache on Windows
  5. Clearing the Visual Studio Code cache on macOS
  6. Clearing the Visual Studio Code cache on Linux
  7. Clearing the Local Storage cache in Visual Studio Code

# Clearing VS Code editor history

When you modify a file, a copy of the old contents is kept in local history.

This allows you to compare a file with an older version from history, however, it can sometimes slow VS Code.

If you need to clear the editor history:

  1. Press:
  • Ctrl + Shift + P on Windows and Linux.
  • Command + Shift + P on macOS.

Note: you can also press F1 to open the Command Palette.

  1. Type Clear editor history and select the option.

clear editor history

Here is a short gif that demonstrates the process of clearing the editor history.

This option is especially useful for clearing deleted or moved files.

# Clearing VS Code search history

Visual Studio Code also keeps track of your searches.

To clear the search history:

  1. Press:
  • Ctrl + Shift + P on Windows and Linux.
  • Command + Shift + P on macOS.

Note: you can also press F1 to open the Command Palette.

  1. Type "Clear search history".

clear search history

  1. Select Search: Clear Search History.

Here is a short GIF that demonstrates the process.

The same approach can be used to clear your command history.

vscode clear other history

Once you start typing clear after you press Ctrl + Shift + P, the options are shown.

# Clearing the Cache in Visual Studio Code

The article has instructions on how to delete your VS Code cache on Windows, macOS and Linux.

VS Code has 2 folders that you have to delete Cache and CachedData.

# Clearing the Visual Studio Code cache on Windows

On Windows, the Cache and CachedData folders are located under:

  • C:\Users\<YOUR_USER>\AppData\Roaming\Code

Make sure to replace the YOUR_USER placeholder with your actual username.

delete contents of cache cachedata

You can also access the folder by pasting %APPDATA%\Code in Explorer.

%APPDATA%\Code is the equivalent of the previous path.

Once you find the directory, open the CachedData folder and delete its contents.

delete cached data contents

You can delete all folders in the CachedData directory to clear the cache.

Then go up one directory and open the Cache directory.

If your Cache directory contains a CachedData directory, open the CachedData directory and delete its contents.

Otherwise, delete the contents of the Cache directory.

delete all files in cache directory

Alternatively, you can use a command to delete the contents of the CachedData and Cache directories.

Open the command prompt (CMD) application and run the following commands.

The following command deletes the contents of the Cache directory.

cmd

 

del /S "%APPDATA%\Code\Cache\*"

windows delete cache command line

Note that you will get prompted multiple times and you have to type Y and press Enter.

If you want to delete the folder without a prompt for confirmation, use del /F /Q.

cmd

 

del /F /Q /S "%APPDATA%\Code\Cache\*"

The following command deletes the contents of the CachedData directory.

cmd

del /S "%APPDATA%\Code\CachedData\*"

Note that you will get prompted multiple times and you have to type Y and press Enter.

If you want to delete the contents without a prompt for confirmation, use del /F /Q.

cmd

del /F /Q /S "%APPDATA%\Code\CachedData\*"

Once you clear the cache, make sure to restart VS Code by closing it completely and reopening it.

# Clearing the Visual Studio Code cache on macOS

On macOS, the Cache and CachedData folders are located under:

  • $HOME/Library/Application\ Support/Code

You might also access the path as:

  • ~/Library/Application\ Support/Code

The easiest way to clean the cache on macOS is to use the rm command.

You can first print the contents of the directories before deleting them.

Open a bash shell and run the following commands.

shell

echo ~/Library/Application\ Support/Code/Cache/* echo ~/Library/Application\ Support/Code/CachedData/*

The following command deletes the contents of the Cache directory.

shell

rm -rf "~/Library/Application\ Support/Code/Cache/*"

You might get prompted. Type y and press Enter if you do.

The following command deletes the contents of the CachedData directory.

shell

rm -rf "~/Library/Application\ Support/Code/CachedData/*"

Once you clear the cache, make sure to restart VS Code by closing it completely and reopening it.

# Clearing the Visual Studio Code cache on Linux

On Linux, the Cache and CachedData folders are located under:

  • $HOME/.config/Code

linux location of cache

One way to delete the contents of the directories is to enter the following commands in your terminal.

shell

cd $HOME/.config/Code nautilus .

The commands will open the Code directory.

You can then open the Cache directory and delete its contents and then open the CachedData directory and delete its contents.

delete cache contents

Alternatively, you can use a command.

You can first print the contents of the directories before deleting them.

Open a bash shell and run the following commands.

shell

echo $HOME/.config/Code/Cache/* echo $HOME/.config/Code/CachedData/*

The following command deletes the contents of the Cache directory.

shell

rm -rf "$HOME/.config/Code/Cache/*"

linux delete cache directory

You might get prompted. Type y and press Enter if you do.

The following command deletes the contents of the CachedData directory.

shell

rm -rf "$HOME/.config/Code/CachedData/*"

linux delete cached data directory

Once you clear the cache, make sure to restart VS Code by closing it completely and reopening it.

# Clearing the Local Storage cache in Visual Studio Code

Visual Studio Code also stores information about which tabs were open before you closed the editor.

This sometimes causes issues, such as the editor always opening multiple projects at launch.

To clear the local storage:

  1. On Windows and Linux:
  • Press Alt to show the top bar and click on Help.

  • Click "Toggle Developer Tools".

  1. On macOS:
  • Click on Help in the top bar and click "Toggle Developer Tools".

toggle developer tools

On both platforms, enter the window.localStorage.clear() command in your developer tools.

shell

window.localStorage.clear()

vscode clear local storage

Once you issue the command, restart VS Code.

You can also clear the local storage in Visual Studio code by issuing a command.

The location of the local storage directory is:

  • on Windows: %APPDATA%\Code\Local Storage
  • On macOS: ~/Library/Application\ Support/Code/Local\ Storage
  • On Linux: $HOME/.config/Code/Local\ Storage

If you need to delete the contents of the local storage directory on Windows, open CMD and issue the following command:

cmd

# Windows del /S "%APPDATA%\Code\Local Storage\*"

delete local storage on windows

Make sure to type y and press Enter when you get prompted for confirmation.

To delete the contents of the local storage directory on macOS, issue the following command.

shell

# macOS rm -rf "~/Library/Application\ Support/Code/Local\ Storage/*"

Make sure to type y and press Enter when you get prompted for confirmation.

To delete the contents of the local storage directory on Linux, issue the following command.

shell

# Linux rm -rf "$HOME/.config/Code/Local\ Storage/*"

delete local storage directory on linux

Make sure to type y and press Enter when you get prompted for confirmation.

Once you delete the local storage directory, close VS Code completely and then reopen it.

I've also written an article on how to solve the issue where VS Code takes up too much memory or CPU.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

Visual Studio Code清除终端的方法有几种。首先,你可以通过修改设置来更改默认的终端。在设置中找到"terminal.integrated.shell.windows"和"terminal.integrated.shellArgs.windows",将其设置为你想要使用的终端路径和参数。\[1\] 另外,你还可以按照一篇Medium上的文章中的步骤,将外部终端替换为新的Windows终端。这篇文章提供了详细的说明和步骤。\[2\] 如果你只是想为Visual Studio Code添加一个快捷键来清除终端,你可以按照以下步骤进行操作: 1. 打开文件->首选项->键盘快捷方式。 2. 修改Terminal.Clear命令的when表达式为"terminalFocus",这样快捷键只在终端聚焦时才起作用。\[3\] 3. 或者你也可以直接编辑keybindings.json文件,添加以下内容: ``` \[ { "key": "ctrl+k", "command": "workbench.action.terminal.clear", "when": "terminalFocus" } \] ``` 这样,你就可以使用Ctrl+K快捷键来清除终端了。 希望这些方法能够帮助你在Visual Studio Code清除终端。 #### 引用[.reference_title] - *1* *2* [vscode 中使用新windows terminal 并修改主题](https://blog.csdn.net/qq_35516360/article/details/122064665)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [vscode终端清屏](https://blog.csdn.net/sinat_34849163/article/details/118659225)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值