Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search: target particular set of files #20530

Open
alvenchen opened this issue Feb 13, 2017 · 158 comments
Open

Search: target particular set of files #20530

alvenchen opened this issue Feb 13, 2017 · 158 comments
Assignees
Labels
feature-request Request for new features or functionality search Search widget and operation issues
Milestone

Comments

@alvenchen
Copy link

alvenchen commented Feb 13, 2017

  • VSCode Version: Code 1.9.1 (f9d0c68, 2017-02-08T23:31:51.320Z)
  • OS Version: Darwin x64 15.6.0
  • Extensions:
Extension Author Version
cpptools ms-vscode 0.10.1

Steps to Reproduce:

1.when i use global search, it's not easy to type whole file path and name in input box,
hope that there is a convenient way to use highlight in search current file by typing ""


Note from @roblourens This includes searching in any particular subset of files such as

  • All open files
  • Files staged in git
  • Recently modified files

etc

@Tyriar Tyriar added the search Search widget and operation issues label Feb 13, 2017
@roblourens
Copy link
Member

Sorry @alvenchen, I don't quite understand what you're asking for

@alvenchen
Copy link
Author

@roblourens Thanks for reply.I wonder is there any convenient way to use global search when searching "current file" or "all open file".

@roblourens roblourens changed the title bad experience for search Search: target open files Feb 21, 2017
@roblourens roblourens added the feature-request Request for new features or functionality label Feb 21, 2017
@roblourens roblourens changed the title Search: target open files Search: target particular set of files Oct 16, 2017
@roblourens
Copy link
Member

roblourens commented Oct 16, 2017

Expanding this to cover searching open files or searching git modified files, or some other class of files.

Edit - Does github not show title edits in the history anymore?

@yuval-gilboa
Copy link

I would also request that you define separate command for starting a search in each search scope, so i can map separate keyboard shortcuts for searching in the different scopes (current file, current folder, open files, all files, etc.). If we have that, it would suffice to cover the use case i requested in #40523, which you've closed.

@yuval-gilboa
Copy link

Any word on this? I don't see much progress for this feature request.

To clarify, we're looking for something like this:

image

Kind of dropdown menu that allows you to select the search scope in the search panel. Possible search scopes can be:

image

In addition, expose a command for each search scope to allow initiating a search in that scope quickly through keyboard shortcut.

@gitnix
Copy link

gitnix commented Jan 30, 2018

@yuval-gilboa That would be great. In addition to the fields you have listed, I would imagine custom search scopes (where user defines exclude/include files) also being available. "tests", for example, would be a good custom scope. I have a separate issue opened for custom search scopes #42350.

@atif089
Copy link

atif089 commented Apr 5, 2018

Friendly bump, I'd love to have this. Thank you!

@ckelley7
Copy link

ckelley7 commented Jun 1, 2018

This is necessary as I use it all the time in VS.NET

@malfusion
Copy link

@roblourens Do you think limiting the scope of the "files to include" field, to the current files/files would be enough to accomplish this? I already have a version of VSCode where i have modified it to do this. I can submit a PR soon if you think that's enough.

@roblourens
Copy link
Member

I don't understand, so if you type in "files to include", it would only search using that pattern in open fils?

@atif089
Copy link

atif089 commented Jun 3, 2018

@malfusion I like the idea, but wouldn't that discard all the unsaved changes in the editor? (also slower because of i/o)

@malfusion
Copy link

@roblourens so the "files to include" is a glob pattern that is searched. So the trick here would be to find the files that are required, generate the glob pattern and then update the "files to include" field with it. And the search would only search the matching files.

@atif089 if the question meant "would the search disregard the current file's unsaved changes", then I'm not sure yet. I'll have to check. But to my knowledge, the search is performed directly on the file system, so only saved changes might be searched.

@bkarlson
Copy link

bkarlson commented Jul 6, 2018

was amazed (in bad sense of this word) to discover VSCode cannot do it... it's 2018 after all, seems to be a common sense feature present in any other code editor or IDE.. bumping the issue to attract attention to it.

@damienleroux
Copy link

+1

@danielo515
Copy link

Is this issue to ambitious? Will it make sense to open a separate issue for the "search on git modified files" for example?

@ghost
Copy link

ghost commented Sep 2, 2021 via email

@yuval-gilboa
Copy link

@JacksonKearl
The new search version is certainly an improvement, thanks for that. But the main point of this feature request is still missed.

The original motivation behind this request was to address the inherent usability problem of having two different search mechanisms in vscode - one on the sidebar and one inside the editor - which results in two sets of search boxes, two sets of search result highlights (overlapping each other and confusing), two sets of keyboard navigation commands (F3 and F4), and a lot of redundant typing and clicking just to switch from one search mode to the other. Not to mention all the accessibility issues that this duality creates.

The new version solves only part of the problem (i.e., search in specific folder / open files), but can easily be extended to cover all the other aspects by changing the "Search only in Open Editors" button from a toggle button to a dropdown button that opens a menu like below. The "files to include" field becomes a combobox that allows quick switching between the different search scopes, including also the recently-used search paths. Up/down arrows can still be used to rotate through this list, but in addition it should be possible to assign keyboard shortcuts for the special search paths (current file, open files, etc).

If this is implemented then it becomes possible to do all searches from single central location, use same shortcut keys to navigate all kind of searches, and have single keystroke/click to switch between the search modes.

5 years since this request was opened, i'm wandering whether this will ever come.
Should a separate issue be opened for this?

image

@popod
Copy link

popod commented Feb 4, 2022

I completely agree with @yuval-gilboa. But I love being able to quickly search into the current opened file with a simple ctrl+f ! It's so useful that I don't think it should be removed.

@ghost
Copy link

ghost commented Feb 8, 2022 via email

@ghost
Copy link

ghost commented Feb 8, 2022 via email

@yuval-gilboa
Copy link

Linking to #75220, which is basically the same request.

@jez9999
Copy link

jez9999 commented Nov 30, 2022

Boy, would I love to have this feature. My main use case is "search in git changes"; I quite frequently find myself searching for stuff in current git changes (whether staged or unstaged) but there isn't really a good way to do it right now.

image

I wish this mockup also included "current Git changes" for clarity!

@jerrygreen
Copy link

«modified files» makes enough sense to me

BTW, was just dreaming about this feature just now, and you bumped it 😄 my use case was just now: search through newly added console.log entries, not just opened files, not entire project, but modified files

but of course there's zillion other use-cases than just mine

@tjx666
Copy link
Contributor

tjx666 commented Mar 11, 2023

find a good extension to support in diff:

https://github.com/Darklaki/vsc-diff-regex

@mickae1
Copy link

mickae1 commented Mar 16, 2023

Boy, would I love to have this feature. My main use case is "search in git changes"; I quite frequently find myself searching for stuff in current git changes (whether staged or unstaged) but there isn't really a good way to do it right now.

image

I wish this mockup also included "current Git changes" for clarity!

When I'm using the extension cmake I would love to search in all the files that the extension cmake Discovered.

You should offer the possibility to the developper of extension the ability to add a group of files in the search menu

@H-G-Hristov
Copy link

Add the ability to save (customize) searches and search locations. Particularly saving presets in "Files to include", "Files to exclude" would be extremely useful.
I often need to search in a very large project but I need to look only in a specific locations and I often need to switch between them. So I'd like to be able to predefine these searches and to quickly select them from a dropdown list when I click on "Files to include" or "Files to exclude".
Similar I'd like to have the ability to save presets in the search field to save any regexes.

I think this request deserves a separate github issue but I see that these get closed as duplicates so I'm typing it here.

@tjx666
Copy link
Contributor

tjx666 commented Apr 21, 2024

try my extension:

https://github.com/tjx666/power-edit#search-in-git-changed-files

2024-04-21.18.49.15.mov

@zargold
Copy link

zargold commented Sep 12, 2024

I came across this issue because I wanted to search for let's say all files that have PureComponent and within those files all instances of . If that's your scenario no need for an extension or for this, but you do need to trick the regex search into giving you /m (multi-line search).

  1. search for something simple like PureComponent (possibly targeting only files with the extension *.tsx, *.jsx)
  2. Click the "Open in editor" link in blue under your search query.

This is because the next search is inefficient and it doesn't help to run it twice. (It can also confirm that the regex search is working as expected.)

  1. Now while searching within editor (on the larger right hand panel): update your search query:
[\s\S\n]*PureComponent[\s\S\n]*

To find all files that use PureComponent (as an example) you can use the regex mode search: ([.*] button in the search)

  • for some reason we need to redundantly target [\s\S\n]* before and after which gives you the full content of a file before and after (all characters or white-space including new lines before and after the exactly matching word "PureComponent").
  1. Results of this search will be vast since every character of each file will appear in results.
  2. Now within the expanded results you can search for <Switch> using cmd+F search within Results view.

This option is pretty quick and easy to use, but your computer will struggle with how apparently inefficient the regex search is.

@rebornix rebornix assigned osortega and unassigned andreamah Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality search Search widget and operation issues
Projects
None yet
Development

No branches or pull requests