microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.39k stars 28.62k forks source link

Search: target particular set of files #20530

Open alvenchen opened 7 years ago

alvenchen commented 7 years ago
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

etc

roblourens commented 7 years ago

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

alvenchen commented 7 years ago

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

roblourens commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

@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 commented 6 years ago

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

ckelley7 commented 6 years ago

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

malfusion commented 6 years ago

@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 commented 6 years ago

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

atif089 commented 6 years ago

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

malfusion commented 6 years ago

@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 commented 6 years ago

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 commented 6 years ago

+1

e105-gamma commented 6 years ago

+1

yuval-gilboa commented 6 years ago

@roblourens

Any update on this? This feature request has been open for a year and a half. I don't see any update regarding this feature for a long time, nor do I have any visibility on your future plans regarding this.

orecht commented 6 years ago

I used "search in open files" a lot in Notepad++. It is especially useful for searching multiple csv files (or other data files).

rdewolff commented 6 years ago

Love this feature!

shahidmau commented 6 years ago

+1 must have feature.

Instagit commented 6 years ago

How about changing the scope of "files to include" with key words like @open, @closed, @modified, @unsaved?

It wouldn't require any UI changes and is easily extendable, so if in the future you decide to make files searchable by modify date, that could be @modified(2d) or @modified(48h) for files that have been modified within the last two days.

I can see this being a very useful advanced feature without needlessly cluttering the UI.

BillDenton commented 5 years ago

From #18796 : "Request ability to search only in the files that are loaded in the editor. In addition it would be good to have a search results window for find (in current file Ctrl+F) so that you can see a list of matches with some context and the ability to copy the search results and click on them to go to the match. This should also work with replace. May be there should be another window like Output, Problems, etc. Ideally this would be able store multiple sets of search results in multiple windows. See SlickEdit for example." I think the ideas have cover most of #18796, but possibly not suggestion of multiple search result windows. It very useful to have multiple search results, particularly when working with log files.

roblourens commented 5 years ago

I think https://github.com/Microsoft/vscode/issues/16488 might cover the rest of that, keeping track of multiple independent searches

mromanch commented 5 years ago

I really love the suggestion from @Instagit!!!

I find it superior to just a UI dropdown, because I can type something like @modified, @open, src/**/*.xml into either the files to include or the files to exclude and anything else that takes file filters could accept the same patterns.

I also love how the idea includes the ability of extensions that extend the filter functionality. (Dreaming :sleeping::heart_eyes::joy::stuck_out_tongue_winking_eye: of GitLens support for @git(52b15e9) allowing me to search within a specific commit.)

Not to mention, if you can accept pre-defined filters, than it's not hard for me to imagine user-defined filters, e.g.:

"search.filter": [
    { "config": ["**/*.config", "src/**/*.cscfg"] },
    { "deploy": ["**/deploy", "@config" },
    { "test": ["**/test", "!**/test/log", "!**/test/out"] },
    { "modified": ["@staged", "@unstaged", "@untracked"] },
    { "unmodified": ["!@modified"] },
    { "src": ["!@deploy", "!@test", "@modified"] },
    { "prod": ["@src", "@deploy", "!@modified"] }
]

Some things to note about the above suggested syntax:

Given the above syntax, the builtin filters only need to support some basic operations like @open and @unsaved. Then @closed simply becomes !@open.

I'm not sure if @folder, @workspace and @project make sense. In the find panel, anything like @folder, or even a UI dropdown will lack context. However, a keybinding for something like find(@folder) probably does make sense.

I feel like minimum Git support is important. Filters for @staged, @unstaged, @untracked and default definitions for "modified": ["@staged", "@unstaged", "@untracked"] and "unmodified": ["!@modified"] would be really nice. I don't know if these are things that must happen in this feature, or just things that must be enabled and support gets left to an extension.

roblourens commented 5 years ago

The custom filters are a really interesting idea.

We recently added intellisense to the extension viewlet and settings search input, could do the same here.

imnickvaughn commented 5 years ago

+1 search open OR git modified files would be used constantly

haugerbr commented 5 years ago

I specifically would like to see at least a current file and all open files option. It doesn't seem like this would be hard to implement. What files would I be looking at in vscode if I wanted to implement this and submit a pull request?

IvanPizhenko commented 5 years ago

+1 for this feature. Especially would like to have "all open files" and "modified files"

IvanPizhenko commented 5 years ago

Any plans to implement this in 2019?

thisisrachelramos commented 5 years ago

+1 all open files search option would be great!

deepaktatineni commented 5 years ago

Any plans to includes this feature?

edespong commented 5 years ago

I will be taking a stab at this based on the ideas of @Instagit and @mromanch

roblourens commented 5 years ago

Sure. Just please discuss your approach with me before spending a lot of time on it.

edespong commented 5 years ago

Basic approach The approach I have looked at is to extend the QueryBuilder to make use of a new 'token expansion' class. The current builder splits the query into glob patterns and makes IExpressions out of them. The idea would be do the expansion between the split and conversion to IExpression. For example, the include pattern *.ts, @open, *.css would leave the *.ts and *.css intact while expanding @open into the file paths of the currently open files (though issue https://github.com/Microsoft/vscode/issues/48958 is blocking for this to work).

Tokens that simply expand into normal globs can also be supported via config.

Extension The actual token expansion will not have any hard-coded tokens, but these would rather be supplied by config and extensions. The ones I have looked at are the editor and git, to support for example open and unsaved files (editor) and changed, staged, etc (git). The extensions esentially use the command framework and the token expander use the ICommandService to call the extension and get the expanded token back.

Syntax The default @ syntax for vscode seems to be @token:parmater, e.g. @editor:unsaved. This can then be shortened or aliased for the most common use-cases, see Configuration.

One question would be how to handle use-cases where multiple parameters are needed and what the delimiter should be. E.g. searching for files changed within the last day. Like @file:modified;24h or @file(modified, 24h).

Configuration Pretty much follows @mromanch idea. Can either define hard-coded globs, combinations of previously defined configuration or reference tokens defined by extensions. Example:

{
    '@config': ['**/*.config', 'src/**/*.cscfg'],
    '@deploy': ['**/deploy', '@config'],
    '@modified': ['@git:changes, @git:staged, @git:untracked']
}

UI Right now, there is only 'files to include', but other programs like Visual Studio also has a 'scope' (e.g. Entire Solution, Open Files, etc). Does it make sense to differentiate between them or will it only be confusing?

Auto-completion? Have not looked into this.

roblourens commented 5 years ago

This sounds great, however it sounds like https://github.com/Microsoft/vscode/issues/48958 will be blocking most of this. Unfortunately that's harder to fix than it sounds because it will involve changing extension API and I will need to drive that.

edespong commented 5 years ago

Yes, I do not see any good way of solving this issue without having https://github.com/Microsoft/vscode/issues/48958 in place. I will keep an eye on if/when it is fixed.

adjenks commented 5 years ago

https://stackoverflow.com/questions/42011289/how-to-search-only-in-currently-open-files-in-vscode https://stackoverflow.com/questions/56086094/how-do-you-search-within-all-open-files-in-visual-studio-code-not-in-a-folder

eminozlem commented 5 years ago

bump . i really need this, this could be the only reason if I ever go back to Dreamweaver. "Search in open files" is very handy šŸ˜„

abhay-gooru commented 5 years ago

that is really a blocker, i came from sublime to vscode, before that notepad ++, vs.net etc all have them, but vscode does not. I have already going back to sublime or searching another alternatives. Soon i find that will dump VS code

Bagnall commented 5 years ago

Support request for "search in open tabs". Please!

vittorioromeo commented 5 years ago

+1 for search (and replace) in open files, it is extremely needed.

gino8080 commented 5 years ago

bump! +1

FabianLauer commented 5 years ago

Guys, please stop "bumping". It triggers notifications for everyone involved in the thread and doesn't add any value. Just hit šŸ‘ in the top comment instead.

carehart commented 5 years ago

One problem with hitting the thumbs up in the top comment is that that top comment (the issue title itself) doesn't convey what nearly all the rest of the comments are getting at: a desire to have a feature to "find in open files/tabs". The OP worded the issue title and even their initial post in a way that does not convey this broader problem. I wish we could more clearly be voting for this broader problem/feature request.

Is anyone (who is a party to this thread) aware of any other issue or PR where attention to this broader issue (a desire to find against open files/tabs) maybe has moved? so that we can drive our support there, more clearly?

roblourens commented 5 years ago

@carehart I consider this to cover that request, and I added a note to the OP to clarify that.

carehart commented 5 years ago

Great. Thanks.

/charlie

eminozlem commented 4 years ago

Yea I am looking forward to this. Every time this thread gets replied I get excited, only to find out it was yet another bump

stderr-to-devnull notifications@github.com, 25 Eyl 2019 Ƈar, 14:34 tarihinde şunu yazdı:

So this has been open for 2 1/2 years, is it so monumentally difficult to implement? Other more basic editor already have this (Notepad++ for example). I need to be able to search in all open file tabs. How many thumb ups are necessary? Maybe I can talk with my family and friends to create accounts and support this request.

ā€” You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode/issues/20530?email_source=notifications&email_token=AAD36PFLHJXMWKYQMTIKZN3QLNEC3A5CNFSM4C73QHN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7RSDEQ#issuecomment-534978962, or mute the thread https://github.com/notifications/unsubscribe-auth/AAD36PFHHBZXEBOGNZ7XJL3QLNEC3ANCNFSM4C73QHNQ .

aetonsi commented 4 years ago

Hi, i found out that i can "search only in open files" by using a backslash instead of a forward slash. Is it a feature? Is it a bug? (if it's a bug i'll open an issue, obv) Demonstration screenshot attached (i was looking for php files inside the "backend/app" folder)

VSCode-win32-x64-1.38.1, extensions disabled, exclude settings/ignore files disabled

image

francoismassart commented 4 years ago

Hi @aetonsi, I just tested this technique on VS Code on macOS and it does NOT work šŸ‘Ž

Here is my config...

VersionĀ : 1.38.1 ValidationĀ : b37e54c98e1a74ba89e03073e5a3761284e3ffb0 DateĀ : 2019-09-11T13:31:32.854Z ƉlectronĀ : 4.2.10 ChromeĀ : 69.0.3497.128 Node.jsĀ : 10.11.0 V8Ā : 6.9.427.31-electron.0 OSĀ : Darwin x64 16.7.0

Cheers

robert1826 commented 4 years ago

I've found a simple solution but it might not work for all scenarios.

scenario: search for a keyword in modified files between two branches (like master and current branch) - I'm using gitlens (kinda solves #82756) steps:

  1. compare the two branches in gitlens to find the modified files in the compare section
  2. right click on 'x files changed' and click open files
  3. to to explorer in vscode
  4. select the open all files under open editors section
  5. right click on the selected files and click copy path (or relative path)
  6. open an new untitled file and paste the paths and then proceed to join all the paths by commas
  7. open search all files and paste the comma joined paths in the files to be searched section

this idea could somehow extend on multiple levels but as you can see it's not the best and I'm definitely waiting for an official solution from the vscode team

jesseko commented 4 years ago

Sublime has a nice model for this that could work for VSCode too.

The text input for which files to search in is paired with a "..." control to get access to these special options. When one is selected, they insert a special entry into the text field. This lets these be used along side other search patterns and makes it easy to always see the full set of active search patterns in one place.

Dropdown at right image

Choose "Add Open Files" image

<open files> is added to the text field image

You can have multiple of these together, and it's easy to delete them at any time image