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

Add "find all occurences" in the current file feature #14836

Open
AxCoder opened this issue Nov 2, 2016 · 129 comments · May be fixed by #7559 or #128915
Open

Add "find all occurences" in the current file feature #14836

AxCoder opened this issue Nov 2, 2016 · 129 comments · May be fixed by #7559 or #128915
Labels
editor-find Editor find operations feature-request Request for new features or functionality search Search widget and operation issues
Milestone

Comments

@AxCoder
Copy link

AxCoder commented Nov 2, 2016

Using Search sidebar to find all items in current file requires too much clicks.
VS has a find all option

  • VSCode Version: 1.6.1
  • OS Version: Windows Server 2008

Steps to Reproduce:

  1. Ctrl + F
  2. Type search test

Expected

option to see all occurrences

Actual

No such option

Visual Studio

snip_20161103091325

VS Code

snip_20161103091454

@rebornix
Copy link
Member

rebornix commented Nov 2, 2016

@AxCoder can you provide a screenshot showing your request as I don't have Windows available right now. It sounds like highlight all selections to me but I'm not quite sure.

@rebornix rebornix added the info-needed Issue requires more information from poster label Nov 2, 2016
@AxCoder
Copy link
Author

AxCoder commented Nov 3, 2016

The difference is that highlight only shows occurrences that are on the current screen while in VS I see all occurences condenced on the bottom pane (similar to the Search sidebar in VS Code). Using of the search sidebar is a workaround, but requires too many clicks
(BTW I tried to copy the full path into the "files to include" it did not find anything)
snip_20161103092432

@rebornix
Copy link
Member

rebornix commented Nov 3, 2016

So let me try to summarize it, you want to see all the search results while using the search palate.

@rebornix rebornix removed the info-needed Issue requires more information from poster label Nov 3, 2016
@Bill-Stewart
Copy link

Have you tried workbench.view.search (default keybinding ctrl+shift+f)?

@AxCoder
Copy link
Author

AxCoder commented Nov 3, 2016

@rebornix

Yes, thank you

@Bill-Stewart

Using Search sidebar to find all items in current file requires too much clicks.

I have not find out how to quickly search only the current file
snip_20161103210238

@Bill-Stewart
Copy link

I don't understand? Pressing the shortcut key means you don't have to use the mouse.

@AxCoder
Copy link
Author

AxCoder commented Nov 7, 2016

@Bill-Stewart the problem with Ctrl+Shift+F hotkey is that is searches in ALL files in the folder, while I want to search only in CURRENT file (active tab). In the screenshot above I'd like to see only entries found in Program.cs not other files.

@alexdima alexdima added feature-request Request for new features or functionality editor search Search widget and operation issues labels Nov 7, 2016
@alexdima
Copy link
Member

alexdima commented Nov 7, 2016

I think this could be implemented by having an action in the editor that invokes the global find in files but scoped only on the current file.

Thus, the search viewlet could show only hits in the current file. fyi @sandy081

@alexdima alexdima added this to the Backlog milestone Nov 7, 2016
@alexdima alexdima removed their assignment Nov 7, 2016
@AxCoder AxCoder changed the title Add a find Add "find all occurences" in the current file feature Nov 7, 2016
@hjma29
Copy link

hjma29 commented Jun 12, 2017

love to have this feature

@sammykun
Copy link

I would also like to see this feature implemented. Additionally, a "Find occurrence in all current opened files" would be a nice extension of this.

@borgu
Copy link

borgu commented Sep 7, 2017

I do it by coping just file name (w/o path) to "file to include" field.

@hma02
Copy link

hma02 commented Oct 19, 2017

This could be similar to the search functionality in Textmate, where you have the option to see all occurrence as an output in a single page and you can then do extra actions like copying those returned occurrence as rawtext. This concept is similar to the output of a grep command.

@Yagger
Copy link

Yagger commented Nov 13, 2017

This can be done by right click on the selection and choosing "Change all occurrences" from the context menu (or CMD+F2).
untitled-2_-_cm-ol

@JoshuaBarnette
Copy link

I agree this feature is necessary. I know we are all perfect coders and never use prefixes or suffixes that need to be changed in certain areas and not others, but the function should be there for everyone else, as it is in nearly every other coding app.

@gibertoni
Copy link

I would like to have this feature as well, since I am using VS Code not only for regular code but everyday file editing as well.

@teiles
Copy link

teiles commented Dec 13, 2017

+1 for this feature - I'm trying to adopt VS Code and the current state of this feature is a paper-cut

@niklabh
Copy link

niklabh commented Jan 9, 2018

#41360

Find all button in other major editors comes with find widget itself. Although vscode provide the functionality as "change all occurrences" from the context menu. It is not readily clear to new developers. Thus this pull request aims to add find all button in find widget. The button is using same command "editor.action.changeAll" as used by "change all occurrences".

I have added svg search icon to find all button using correct color scheme. Please change if required.

findall

@lachieh
Copy link

lachieh commented Mar 7, 2018

This is crucial. You can't select all occurrences of a RegEx search without this functionality.

@d-akara
Copy link

d-akara commented Mar 7, 2018

@lachieh You can use command 'select all occurrences of Find Match' to select all occurrences in a single file.

@rebornix rebornix removed their assignment Oct 22, 2021
@m1chae1bx
Copy link

m1chae1bx commented Oct 22, 2021

Just to provide an update on this, we've been exploring adding a "Filter" on the find widget that would allow the options to scale better. Since we already have "Find in Selection" as a toggle, we thought it would be best to follow the pattern we use in the "Problems" panel and using the filter action for the toggle. Here's how that would look like for the find widget:
image
Happy to hear any feedback on this as this is where the "Select all matches" action would live

One more option would be 'list all the matches', with that copy the list , it was very convenient in notepad++.

True, this feature in notepad++ is very handy. It was disappointing to not see this in VSCode. In my case, I don't really need to have the matches selected; rather, I wanted to see a list of all occurrences to quickly glance at each result in their context.

@moldovans
Copy link

waiting that feature, I would like to see all occurences in the current file of a string in a list, and also more details, like in what function(parent) each of the occurences is.

@Rufus-SN
Copy link

Rufus-SN commented May 3, 2022

Notepad++ has those options: Find in current file, and Find in open files. To their credit, I like the fact that VSCode allows you to copy your search results back into a text file! For now, I guess I'll have to save my current file, and select the name as a file filter for the "find all".

@wilon
Copy link

wilon commented May 7, 2022

image
image
image

@Fairy-wen
Copy link

Need it to !
I'd like not to have to open another editor to find all occurrences of a word in a file.

@gulshan
Copy link

gulshan commented May 13, 2022

Hi Everyone, I think this existing option in the vscode search panel can help-

image

@Rufus-SN
Copy link

@gulshan Yes! I just found out about the "Search Open Editors" Icon the other day! That will serve about all my uses of "Search Current File" for all practical purposes!

@gpnaveen
Copy link

@gulshan Yes! I just found out about the "Search Open Editors" Icon the other day! That will serve about all my uses of "Search Current File" for all practical purposes!

Is there a way we can copy the search output?

@Rufus-SN
Copy link

@gulshan Yes! I just found out about the "Search Open Editors" Icon the other day! That will serve about all my uses of "Search Current File" for all practical purposes!

Is there a way we can copy the search output?

Just right-click one of the hits, and it will give you a Copy-All option. Copy, create a new file, and paste the results!

@mat-m
Copy link

mat-m commented Sep 1, 2022

Hello, Opened Editors is nice and have its benefits, but I often have a big bunch of them opened, so it is not like a dedicated "Find all in current document:editor" for my use case.

Edit: OK, we have a PR waiting for 1 year now...

@FSGCorp
Copy link

FSGCorp commented Oct 10, 2022

Wow. Yeah, this is like the most basic feature of a code editor. Hard to believe this isn't available.
This is from UltraEdit which I thought I was going to abandon after 20 plus years for VS Code but not sure now. VS Code should have most if not all of these find options.
ue-find

@avastar
Copy link

avastar commented Oct 15, 2022

I learned of vscode today and thought it was the best.. until I found that my most used feature of Notepad++ was missing... Where is the "Find All In Current Document" button? It seems like a 2 minute implementation since all the code is there, just limit it from "Search Only in Open Editors" to "Search Only in Current Editor".

I sometimes have 20+ files open in the editor. I don't want to scroll through all of them and all of their results to find the results for the file I'm currently working on.

@helfri62
Copy link

I'm with @avastar, this is one of my most used features in Notepad++. I'm still experimenting with UltraEdit. I love VS Code's integrations and extensibility, but this is a real usability limitation for me.

@DerekSMorin
Copy link

Hi Everyone, I think this existing option in the vscode search panel can help-

image

I think this is a good start. Maybe we just need one more button beside this with only one page ( meaning the current file ) instead of just the button for all open files.

@FSGCorp
Copy link

FSGCorp commented Oct 19, 2022

Please tell me if I got this wrong, I am new to VS Code and seems a lot has changed in the six years since this issue was first opened and the issue seems to have proliferated the internet in various forms so if you search for something like "vs code find search only in current file" you get ton of results and if you don't read the details then you would think as I did at first that there is no way to do a simple "search/find in only the current file".

To clarify, there are two functions:

  1. "Find (Ctrl+F)" which is a simple find in the current file
  2. and then there is "Find in Files (Ctrl+Shift+F)" - taken from the Edit menu text - which is also available from the sidebar search icon with Tooltip text "Search (Ctrl+Shift+F)". So same function is referred to as "Find in Files" and as "Search" and they are the same thing.

The simple "Find (Ctrl+F)" seems to behave as expected limiting scope to the current file only. The real issue which seems to get lost in the back and forth on these posts is that you cannot do a simple "Find" (in current file only) and list out the results to a separate window which may still be an issue. It is certainly a nice to have and should be available and is available in UltraEdit which I am currently using. Please correct me if any of this is off. I'd love to understand better.

I'm not pushing UltraEdit but it seems like they have made a company out of recreating an editor with all the features of VS code but user friendly, and keeping up with VS code's improvements and addressing all the quirks that people are complaining about with VS code. I've been using UltraEdit for more than 20 years and I am only exploring it now b/c all the youngsters in my new group are using it. First glance it appeared to be the bomb and I was ready to switch over but upon further inspection it seems to be a bit out of control and it's flexibility has made it inflexible and is now a hinderance. It's hard to be an editor for everyone, and especially to such a contentious group of people (self included). 😄 MS Curse 1.0 - trying to meet the needs of all with a single product which eventually gets out of control and becomes unmanageable. ☹️

@burekas7
Copy link

burekas7 commented Nov 5, 2022

I would like to have this feature as well.
2022 - Any update on this?

@zm-cttae
Copy link

zm-cttae commented Jan 15, 2023

Seeing a list of "find" results in a new editor or the left pane is useful - as this would probably be a new-file icon following the existing implementation of the search pane. I think #128915 solves that part.

Putting find-in-selection in a filter makes sense to me, because it changes the find-replace widget's behavior of incrementing the selection. Doubtful that select-all-matches would intuitively live there IMHO.

I personally want a select-all button that could even use the expand-all or plus icons:

  • UX-wise, the button puts the user on a different path of action than the other functionality of the search menu - "select all, then add to OR destroy, also maybe replace with typed text".
  • It's easier to understand - filter means (hopefully) less whereas select-all means more/all-the-things.
  • Say our user has pressed select-all but has not typed in a new string for all those ranges. To toggle back, we add a search-clear-results icon to go back into the incremental search mode. Just a problem of deciding the position of the current selection - the user could have scrolled up or down a "page", or to the very top or bottom. "First visible result" could work.

zm-cttae added a commit to zm-cttae/vscode that referenced this issue Feb 2, 2023
We use `expand-all` for the "select matches" icon.
We also rename from "find all" to "select all" for microsoft#128915.
Refs: ec02bcd & microsoft#14836
@zm-cttae
Copy link

zm-cttae commented Feb 5, 2023

2022 - Any update on this?

@burekas7 I made yisibl#1 and suggested a review on the other pull #128915 (comment)

@netjeff
Copy link

netjeff commented Apr 5, 2023

@sreenadh commented on May 3, 2019

Right-click on tab, "Copy relative path"
Ctrl+Shift+F to open Search sidebar - enter search query
Paste the relative path in "Files to include"

This workaround is what I'm using. The important thing is to "Copy Relative Path", not the plain "Copy Path".

Still more clicks than I'd like, but not too bad. Hopefully there will be better support for this someday ...

@burekas7
Copy link

burekas7 commented Apr 10, 2023

@sreenadh commented on May 3, 2019

Right-click on tab, "Copy relative path"
Ctrl+Shift+F to open Search sidebar - enter search query
Paste the relative path in "Files to include"

This workaround is what I'm using. The important thing is to "Copy Relative Path", not the plain "Copy Path".

Still more clicks than I'd like, but not too bad. Hopefully there will be better support for this someday ...

+1

2023 - Any update on this?

@jamesford42
Copy link

jamesford42 commented May 16, 2023

This is highly annoying and makes me not want to use VS Code for files that are more than a few hundred lines. When you search a bigger file, such as a log, you generally want a usable summary of line results so you can see which of the 100 results is the one you care about.

@jborovi
Copy link

jborovi commented May 18, 2023

Hello, this is great plugin, thank you for that, but "search all occurences" should not be text search (CTRL+SHIFT+F)... I would expect that it will find really all occurences of the specified variable... not all strings which have same name, for example if developer names local variable X, I only need to find all occurences of this local variable X, not every occurence of string X in the code. This is what means "search for all occurences" in all IDEs.

@andywhitaker
Copy link

I would probably just make a button within the normal search box or item in the cmd+p menu that brings up a search editor or the search pane with the files filter already filtered to the specific file that was open with focus when it was initiated. If a button in the existing search is used to trigger this then have the search token field populated with whatever term was there originally as well before triggering the "find in all files". I imagine this would use already existing capabilities and take minimal effort as compared to other options. I'm honestly getting along just fine without this now but thought I'd make the suggestion. My workaround has been to basically use the search panel and type in what I need to filter to the specific file I want or use a search editor and do the same. Having it pre-filter to the file easier would be a minor plus for me but I don't really care that much anymore.

@noam-zur
Copy link

noam-zur commented Nov 5, 2023

(coping here my suggested solution from #197271 - which I opened before I realized this feature request exists already...)
(1) Add "New Search Editor" button to the "Search in File" panel.
(2) When pressed, it will open a new Search Editor window. it will be already configured for 1. single file search (the origin file) 2. the same search query.
example mock:
image

@amunger amunger added the search Search widget and operation issues label Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor-find Editor find operations feature-request Request for new features or functionality search Search widget and operation issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.