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

Better UI for Multiline Search & Replace in a single file #15727

Closed
anacondaq opened this issue Nov 18, 2016 · 81 comments
Closed

Better UI for Multiline Search & Replace in a single file #15727

anacondaq opened this issue Nov 18, 2016 · 81 comments
Assignees
Labels
editor-find Editor find operations feature-request Request for new features or functionality ux User experience issues
Milestone

Comments

@anacondaq
Copy link

I'm new to VSCode, i like many things in this editor, but i miss a lot of really useful and important options which missing for some reasons at Visual Code. One of such feature is Powerful Search Options.

About what i'm talking about?

What will you see on image above?

  1. Multiline Search which will search in opened document for the text. Also, this feature support searching for multiple lines at once in multiple documents very easy.
  2. Multiline Search when you enter in search fild your lines automatically find in text this text (if it exist) and highlite it
  3. You can manipulate with multiline search the same like with one-line search.
  4. You can select multiple lines via ALT + SHIFT + Arrow Up / Arrow Down multiple lines, then you can click HOME button and all lines will be selected with multiple cursor and you can apply some changes to your multiline search like below:

Multiline Searching And Line Manipulation in search field

Why multiline feature like in sublime text should be implemented?

Because of this feature, time saved in 10-20x times. People like me who working with a lot of patches, reject hunks, etc things and working with a lot of searching things will find this features very useful. Example of usage can be: fixing .rej files, applying patches, big diffs, applying some changes to multiple lines at once.

Please think about it well, this feature is market-killer, and in one day even if you reject the issue today, community will request this feature for sure, no exeptions, just time will show. Because this feature minimize stupid tasks and time for doing the same job, productivty increased, all happy.

More info about feature: http://docs.sublimetext.info/en/latest/search_and_replace/search_and_replace.html

@ramya-rao-a ramya-rao-a added search Search widget and operation issues editor-find Editor find operations and removed search Search widget and operation issues labels Nov 18, 2016
@sandy081 sandy081 added the feature-request Request for new features or functionality label Nov 21, 2016
@sandy081
Copy link
Member

sandy081 commented Dec 7, 2016

@Anacondaqq VS Code also supports multi line search in a file for which you need to enable regex option and provide eol characters for line separators. But, I see that in your video it makes much easier to copy multiple lines and search for it just by pasting it and I liked it.

@sandy081 sandy081 added the editor label Dec 7, 2016
@sandy081 sandy081 added this to the Backlog milestone Dec 7, 2016
@alexdima alexdima removed their assignment Dec 8, 2016
@anacondaq
Copy link
Author

I saw Electron & VSCode source code, and i think my request will be very hard to implement...
This is so bad... 😿

@michaelperrin
Copy link

This is one of the features I miss the most indeed.

Finding and replacing chunks of text (I mean multiline text) is really useful. Using \n is not a solution, as you need to make the change the text you have copied before pasting it to the search and replace inputs.

I would therefore really like to get "textareas" instead of "input text" fields for search and replace fields.

@sandy081 sandy081 assigned alexdima and unassigned sandy081 Mar 8, 2017
@rebornix rebornix self-assigned this Apr 28, 2017
@tobia
Copy link

tobia commented May 4, 2017

I used this feature all the time too: just paste a chunk of code (or data) that you need to search and replace, then iteratively convert it into a regexp (replacing stuff with (.*?) or other capturing groups) and use the captured groups in the replacement string (also multiline)

@anacondaq
Copy link
Author

@tobia i don't get you, explain. Can you show any illustration?

@ariesy
Copy link

ariesy commented Jun 20, 2017

I have been using this feature in sublime text a lot, really need it in vscode so I don't have to use two text editor.

@alexdima alexdima removed their assignment Jun 20, 2017
@shikkaba
Copy link

shikkaba commented Sep 6, 2017

Will this be implemented soon? I really miss this feature.

I like how Dreamweaver does multiline search. Haven't used Sublime.

@rnemec
Copy link

rnemec commented Sep 6, 2017

Looks like it got lost in the #26498 re-scoping. Originally, that was thought to be precursor for this issue, but then they decided (correctly I believe) to take what was already done (horizontal resize) and split it. But not sure where the vertical aspect of the Find Widget landed. And it is now definitely disconnected from this issue.

@rebornix , could you please look into reviving this issue and perhaps relink it with the proper underlying work/issues?
Also, if somebody feels that this issue still needs more clarification or justification, please, let us know too. (All the reporters here, we may be under impression that the problem is "obvious, anybody can see it")

@soundstep
Copy link

+1
Missing this feature as well!

@louy2
Copy link

louy2 commented Sep 28, 2017

I found this thread after I failed to understand how to use multiline regex to match what I want. I wanted to delete blocks of the same HTML that was copied and pasted throughout a document. I did not know that Sublime Text has this feature, and after changing to it, finished the operation in no time.

@anacondaq
Copy link
Author

@louy2 this is killer-feature.

@ArmorDarks
Copy link

I must admit that VS Code searching UI and UX is total disaster in comparison with Sublime Text. One of the most important aspects of text editor takes a lot of time to do trivial things after Sublime Text, not to mention very unpleasant form — little widget, which you will quickly hate if you need to write often there big chunks of texts, which simply do not fit.

And yeap, lack of Search all button is lackluster too.

Also, would be great to see option to always keep Replace field expanded. Expanding it takes precious time.

@louy2
Copy link

louy2 commented Oct 28, 2017

@ArmorDarks
To open Replace field directly in VS Code you can use ctrl-shift-h

@roblourens
Copy link
Member

@lehni Please open a new issue rather than adding new discussion to an old issue with 50 people subscribed.

@garretwilson
Copy link

garretwilson commented Oct 16, 2018

I want to point out that I can do the following in Atom:

  1. Select several lines of code.
  2. Press Ctrl+F to bring up search.
  3. Press Ctrl+E to bring the current, multiline selection into the search box.

Then I hit <Enter> and do my search. That's all there is to it.

I don't need fancy dragging and live selection and stuff. I'm sure that's useful, and I have nothing against it. I'm just saying this simple capability would make search so much better and fix a large part of this defect.

But it looks like someone already closed #47400 for whatever reason. 😦

@smxdevst
Copy link

@garretwilson Thats exactly what we need in vscode

@hickford
Copy link
Contributor

I greatly prefer the search bar in Sublime Text to that in Visual Studio Code:

  • Search bar is full width of window and different background colour
  • Search bar at bottom rather than at top
  • Text box allows line breaks (Ctrl+Enter), expands to fit
  • 'Find all' button

Because the Visual Studio Code search bar covers partial lines of code, and is the same background colour, I find it particularly difficult to read

@garretwilson
Copy link

I don't get it. VS Code is so great, yet when I need to remove a few <br /> elements a WYSIWYG editor has added to my code (along with newlines), then I have to bail out of VS Code and use another editor just to replace them!

I seriously cannot figure out how to do a multi-line search and replace in VS Code.

  • I don't want to go into some sort of escape mode and figure out how many escaped tabs I need to add.
  • I don't want to go into some sort of regex mode and try to match whitespace and use some clever matching group replacement—seriously, I have work to do.

As I mention above, in Atom (before I switched to VS Code) I just:

  1. Select several lines of code.
  2. Press Ctrl+F to bring up search.
  3. Press Ctrl+E to bring the current, multiline selection into the search box.

Then I hit <Enter> and do my search. That's all there is to it.

Maybe I'm being dense and missing something simple. Is there a way I can simply select a block of text, and say, "Hey, VS Code, this is what I want to search for; I'll tell you what to replace it with." Can I do that? If not… why not?

@JakubRimal
Copy link

@garretwilson What version of vscode do you have? This feature has been added in November 2018 (see https://code.visualstudio.com/updates/v1_30#_multiline-search-input). For me it works great:

  1. select multiline text
  2. Ctrl + C
  3. Ctrl + Shift + f
  4. Ctrl + V
  5. Enter

I think that this issue should be closed as it is done. Thank you vscode for adding this!

@JunhwanPark
Copy link

@JakubRimal Oh! I didn't know that!!! Thanks.

@DisasterMan78
Copy link

That's a definite step forward, but it would be nice to have that in file search, not only project-wide. If you want to do a multi-line find and replace on just one file, this isn't so convenient (thought workable).

Hopefully translating the fix from project search to file search shouldn't be a great leap, and it would be an incremental UX improvement that is worth having.

@garretwilson
Copy link

This feature has been added in November 2018 …

But isn't that for multifile search+replace? I just have a single file open. @JakubRimal , how do a do a multiple search+replace just inside the single file I have open?

@JakubRimal
Copy link

@DisasterMan78 @garretwilson You can do it using "files to include" field (Ctrl + Shift + Alt + C to copy a relative path of the current file).

But you are right, I missed that the original question is also about a single file (but the question description mention "multiple documents" as well).

@garretwilson
Copy link

So how do we get more visibility for this ticket and raise the priority of this? Any ideas?

@garretwilson
Copy link

It looks like this is assigned to @rebornix and @misolori . Maybe one of them can give us an update and a timeline for getting this done.

@mamiu
Copy link

mamiu commented Feb 8, 2019

how do a do a multiple search+replace just inside the single file I have open?

@garretwilson I always use multi cursor selection for that. It's by far better than every search functionality, as soon as you're getting used to it.

Just select the part you want to "search" for and then press CTRL-D (or CMD-D on Mac). Repeatedly press this shortcut until all occurrences you want to select are selected. In case you want to skip one occurrence during that process, press CTRL-K CTRL-D (or CMD-K CMD-D on Mac) and the latest match will be skipped. If you want to select all occurrences in the whole file, just press SHIFT-CTRL-L (or SHIFT-CMD-L on Mac).

Train the above techniques, until you have them in your muscle memory, then it'll save you a lot of hassle. There are even more things you can do with the multi cursor selection that you should definitely learn: https://code.visualstudio.com/docs/getstarted/tips-and-tricks#_multi-cursor-selection

@garretwilson
Copy link

Wow, @mamiu , that is a great workaround, thanks so much for telling me about it. It turns out that after making the selection using Shift+Ctrl+L, I can even move the cursor around if I'm careful.

Still, it's a little tedious and isn't an excuse for the VS Code team not to implement a decent multiline search+replace for a single file.

But this will help greatly for now. Thanks again.

@rebornix
Copy link
Member

Latest Insiders ships the first version of multiple line find and replace support in the Find Widget. You can press Ctrl+Enter to insert new lines in the input box.

multiline

@ArmorDarks
Copy link

Nice!

Now what's left to complain is extremely tiny input size. That's exactly what you want when searching code snippets

CRM4sA8

@rebornix
Copy link
Member

@ArmorDarks you can resize the find widget by dragging the left most sash when necessary.

@BobSeu
Copy link

BobSeu commented Aug 23, 2019

@rebornix Is this something you have to enable? I tried to do this, but it remains single line for me.

@rebornix
Copy link
Member

@BobSeu you can paste multiple line into the find input box or press ctrl+enter to insert a new line, current Insiders has a bug where pressing ctrl+enter doesn't work when the cursor is at the beginning of the input box, which should be fixed in tomorrow's Insiders (see #79893).

@anacondaq
Copy link
Author

Like Russian saying: "the promised three years are waiting".
You did this! Finally, you did it after almost 3 years after opening the issue.
I'm so happy and proud of all of you. Now I can finally remove sublime text from my PC and focus only on VSCode because VSCode does things much better and does not luck any missing features for me what I did miss 3 years ago after trying VSCode but keeping it installed on my pc. Thank you all!

@mamiu
Copy link

mamiu commented Sep 11, 2019

@anacondaq Glad to hear that you're happy now! Then please close the ticket.

@rebornix
Copy link
Member

Closing this issue as we shipped multiple line find and replace support.

@vscodebot vscodebot bot locked and limited conversation to collaborators Dec 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-find Editor find operations feature-request Request for new features or functionality ux User experience issues
Projects
None yet
Development

No branches or pull requests