I think you hit on the only real difference. They both have the same default keybinding but the view version does have a context arg of:
!searchViewletVisible
so it is really meant just to surface the search panel when it isn't visible. But the findInFiles version will make the search panel visible too. The only real difference is the ability to take arguments - which I think very few people know about.
As you point out, the findInFiles version can take arguments - which I didn't know before!! So it is worth showing how. Like this:
{
"key": "ctrl+shift+f", // whatever keybinding you wish
"command": "workbench.action.findInFiles",
"args": {
"query": "${selectedText}", // variables don't work
"replace": "that's $1 swell",
"triggerSearch": true, // seems to be the default
"filesToInclude": "${relativeFileDirname}", // no variables
"preserveCase": true,
"useExcludeSettingsAndIgnoreFiles": false,
"isRegex": true,
"isCaseSensitive": true,
"matchWholeWord": true,
"filesToExclude": "./*.css"
}
},
Full list of available args for workbench.view.search:
"query": "",
"regexp": "",
"wholeWord": "",
"caseSensitive": "",
"includes": "",
"excludes": "",
"showIncludesExcludes": "",
"useIgnores": "",
"contextLines": 0,
"triggerSearch": "",
"focusResults":
The list of args above is being transitioned to those below (see https://github.com/microsoft/vscode/commit/2fdc8c336c601e385fadfaa1802cdc67fea96241) to be consistent with the findInFiles command. I assume the old args will work for some period of time but the new ones are in the Insiders' Build v1.51 so should be in Stable soon.
"query": ""
"isRegexp": true,
"isCaseSensitive": false,
"matchWholeWord": true,
"filesToInclude": "",
"filesToExclude": "",
"showIncludesExcludes": false,
"useExcludeSettingsAndIgnoreFiles": true,
"contextLines": 2,
"triggerSearch": true,
"focusResults": true
If you have a commonly used search/replace this could be valuable and could be assigned to unique keybindings.
workbench.view.search can not take preset arguments, but search.action.openNewEditor can! See https://stackoverflow.com/a/62207896/836330 for more.