Search code examples
visual-studio-codecommand-history

VSCode - How to delete a specific command history in command palette (as opposed to clearing everything)?


I would like to delete several commands from VSCode command palette's "recently used" section, but not clear the entire history. How?


So in Chrome's Omnibar, you can use Shift+del to delete a suggestion. But I cannot find an analogous shortcut in VSCode's command palette.

I also looked for a "meta-command" for this, but I only found Clear Command History in the command palette. I want something like Edit/Manage Command History instead.


Edit: a history file that I can directly edit (analogous to ~/.bash_history for Bash) would also do.


Solution

  • This is based on the response by cyqsimon; but, for Windows, it's (on my machine) located under:

    %AppData%\Code\User\globalStorage\state.vscdb
    

    This is a SQLite database file, and can for example be opened and edited with SQLite DB Browser.

    So, close Visual Studio Code, and the entry key in this database file that needs to be changed is:

    commandPalette.mru.cache
    

    And, if you want to clear everything, you can (at least with the current version at the time of writing) change its value to this Json:

    {"usesLRU":true, "entries":[]}
    

    If you just want some of them you need to edit the json values as you see fit. You might also want to reset:

    commandPalette.mru.counter
    

    and set its value to 1. Or however many entries you choose to keep in the json entries list +1 (at least it seems that way after a bit trial and error). But if you don't clear the list completely in the previous json-chunk you probably want to change the numbers referenced there too.

    Save the file and restart Visual Studio Code.