Open meganrogge opened 3 years ago
Do you want to search in the line with the match, and the surrounding lines, or anywhere in the file? If the first, try Search Editors.
Anywhere in the file
It would've saved me so much time to have this capability on 3 unique occasions today. Talked w @kieferrm and I hope to work on a PR for ripgrep in the coming iterations so that we have a:
SearchTerm1 && SearchTerm2 option
Could also be a good extension candidate using the (proposed) findTextInFiles
API.
For your original case, it sounds like what I often use "files to include" for, when I want to search for the use of a term like ipad in some feature area like notebooks, I would use notebook
or *Notebook*
(note that it's case sensitive)
I made an extension which applies a workaround by copying the current search results, regex-ing for the filenames, getting their relative paths and then putting those paths into the 'files to include` filter. Find and Transform.
Specifically Using the Search Results files in another search.
Use from the context menu, Command Palette or a keybinding like:
{
"key": "alt+shift+f",
"command": "runInSearchPanel",
"args": {
"find": "Second", // plus all the other args from the findInFiles command
"replace": "Third",
"filesToInclude": "${resultsFiles}", // !!
"triggerSearch": true
},
"when": "hasSearchResult" // I suggest this but it isn't mandatory
}
There are other ways to use the ${resultsFiles}
variable as well. Such as in the find-and-transform.searchInResults
command where it is automatically applied.
Using this keybinding:
{
"key": "alt+z",
"command": "runInSearchPanel",
"args": {
"filesToInclude": "${resultsFiles}",
"triggerSearch": true,
}
},
Demo:
[Since the context menu item for this really belongs in the Search results context menu but that is not currently exposed to extensions, I am going to file an issue requesting it. See https://github.com/microsoft/vscode/issues/127896]
I'd like to be able to search for something, for example
ipad
and then in the files which contain that term, search for something else, for exampleterminal
.IE find files which contain && .