VS Code has a useful feature that keeps your search history across sessions.
It applies to:
- workspace searches (
CTRL
+SHIFT
+F
orCMD
+SHIFT
+F
on macOS) - editor searches (
CTRL
+F
orCMD
+F
on macOS) - keyboard shortcuts searches (
CTRL
+K
CTRL
+S
orCMD
+K
CMD
+S
on macOS) (and maybe other areas as well that I’m not currently aware of)
The search history persistence means your search queries are saved and automatically available even after you close and reopen VS Code, making revisiting previous queries easier.
In this article, I will show you how the search history persistence works, the difference between workspace search history and editor search history, and how to disable the latter.
🎥 Prefer a video instead? Check this out:
How It Works
The search history is saved on a per-workspace basis. This is great because it ensures that the search history from another project doesn’t interfere with searches from another project.
Press CTRL
+ SHIFT
+ F
or CMD
+ SHIFT
+ F
on macOS to open the global search widget and CTRL
+ F
or CMD
+ F
on macOS to open the editor search widget.
Then you can use the ↑ UpArrow
and ↓ DownArrow
keys to browse through the search history.
You can do the same in the Replace section of the workspace and editor search widget.
Global Search vs Editor Search
It’s important to note that the global search and editor search maintain separate histories.
The history from your global search will not appear in the editor search history, and vice versa.
This distinction ensures that you can keep both types of searches organized independently.
Disable Editor Search History
If you’d want to disable the search history persistence feature, you can only do this for editor searches, not for workspace searches.
Unfortunately, I haven’t found a way to turn off this feature for workspace searches. If you know the setting for it, please leave a comment below.
To disable the editor search history persistence, follow these steps:
- Press
CTRL
+,
(comma) orCMD
+,
on macOS to open Settings - Alternatively, you can go to File > Preferences > Settings and search for
editor.find.history
. From the dropdown, select thenever
option.
You can also directly modify your settings.json
file by adding the following line:
"editor.find.history": "never"
That’s it! Now your editor search history will be cleared across sessions and hopefully you’ve got a good handle on how the persist search history works in VS Code.
Happy coding đź’ś
Let me know what you think about this article in the comments section below.
If you find this article helpful, please share it with others and subscribe to the blog to support me, and receive a bi-monthly-ish e-mail notification on my latest articles.