The current editor I have open contains the name of a file or part of the name of a file that I have in my workspace. I want to search for that file by selecting the text of that name from the editor, and then putting that text in the Quick Open search box. Currently, I need to manually copy and paste the text, but I want to have behaviour similar to the cmd + F
search box where the selected text from the editor immediately appears in the search bar when it is opened. Is it possible to configure Quick Open to do this as well? Or maybe there is an extension for this?
At the time of this writing, this is currently not configurable in a way that is nicely builtin to VS Code.
You can create a keyboard shortcut that emulates the behaviour like this (put in keybindings.json (open that file with Preferences: Open Keyboard Shortcuts (JSON)
in the command palette)):
{
"key": "ctrl+b",
"command": "runCommands",
"args": {
"commands": [
"editor.action.clipboardCopyAction",
"workbench.action.quickOpen",
"editor.action.clipboardPasteAction",
],
},
},
Note that since this workaround involves copying to the clipboard, it will clobber whatever you had in the clipboard before that, which you might not want (but unfortunately, I can't think of another workaround).
If you're happy with the workaround, then read no further. If you want something nicer, keep reading.
If you look in the settings, all the settings that allow enabling or disabling this behaviour contain the word "seed
" in them: search.seedOnFocus
, search.seedWithNearestWord
, editor.find.seedSearchStringFromSelection
. From my reading/searching, there is no other setting with the word "seed
" in it.
I googled "github vscode issues quickopen seed
" and found this GitHub feature-request on the VS Code GitHub repo: Fuzzy quick open should use selected text as a starting point #59957 asking for such behaviour to be the default behaviour. The issue didn't get enough support from other users to get added to their backlog (a feature request needs to get a certain number of thumbs up reactions from users within a certain time period after it is created to get considered for implementation), so that feature-request is now closed.
If you want to get such a configuration option, create a feature-request issue ticket. If you want to increase your feature-request's visibility (and therefore its chance of getting enough user support), share a link to it on various programming platforms such as r/vscode. One got raised at https://github.com/microsoft/vscode/issues/232799.
I didn't find any extensions that do this by googling "vscode marketplace quick open seed
" and looking at the top results, but maybe you'll have better luck with different queries.