There has been quite a bit of discussion (1, 2, 3) about whether "find" in vscode should default to the whole file, or to the selection. The discussion seems to have converged toward disabling "in selection" by default, but providing the configuration option "editor.find.autoFindInSelection" to change this default (with three options never, always, only on multiline selection).
However, I find that in my workflow I never want the "in selection" active when I do a simple find, but I do want it when I do a find/replace with a multiline selection.
Is there a setting to only toggle "in selection" when I invoke find/replace (Ctrl+H for me), not for a simple find (Ctrl+F for me)?
Is there a setting to only toggle "in selection" when I invoke find/replace (Ctrl+H for me), not for a simple find (Ctrl+F for me)?
You could set up the following keybindings using the new command editor.actions.findWithArgs
:
{
"key": "ctrl+f",
"command": "editor.actions.findWithArgs",
"args": {
"findInSelection": false,
// "isRegex": false,
}
},
{
"key": "ctrl+h",
"command": "editor.actions.findWithArgs",
"args": {
"findInSelection": true,
// "isRegex": true,
"replaceString": "",
}
}
These mostly work. I have filed a bug: https://github.com/microsoft/vscode/issues/141683
If the Find Widget is closed, these do work as expected. Although you will only get the Find In Selection
option enabled if you have a selection when you trigger Ctrl+H. I think that requirement is okay.
What doesn't work and is the subject of the issue is if the Find Widget is already open and you Ctrl+H, the Find In Selection
option is not disabled. It should be - the isRegex
option is disabled in this case as per the above keybindings.
So almost there if the issue is resolved.