microsoft / vscode

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

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

Closed anacondaq closed 5 years ago

anacondaq commented 7 years ago

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

soundstep commented 6 years ago

That's not something you should say for a free tool. If you are not happy with the speed, get the job done and do a PR.

On 8 September 2018 at 19:58, anacondaqq notifications@github.com wrote:

@roblourens https://github.com/roblourens good to hear that, that at least after 2 years of the issue it got checked, and will begin development. ping me back somewhere in 2020 when the feature will be ready. Thx

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Microsoft/vscode/issues/15727#issuecomment-419665449, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIIrdS3W6CtmrsE1ZPlsi4Mv7N1kgjBks5uZBNpgaJpZM4K2fYI .

-- www.soundstep.com

travisfisher commented 6 years ago

@roblourens the current search and replace fields in VS Code are one line fields. In ST, when you drag the search panel up to be larger, it expands the search and replace fields, which is a nice feature when you're searching / replacing hunks of code because you can see the full hunks (as in the original example provided). How do you see that being handled with VS Code's UI? Could the area where the search and replace fields exist have a drag handle that you could use to expand up and down to expand those fields?

Thanks for staying tuned on this issue. I'm really looking forward to making the switch away from ST once it gets implemented.

roblourens commented 6 years ago

Yeah, we'll have to do something like that, but I'm not sure what it will look like exactly.

roblourens commented 6 years ago

I realized we have an earlier duplicate for this issue - https://github.com/Microsoft/vscode/issues/13155

roblourens commented 6 years ago

Sorry, sorry, I keep missing that this is for find in a single file

anacondaq commented 6 years ago

@roblourens please stop acting like a kid because of my comment which looks "toxic" above. Stop trying to close the issue or rename it, etc, or finding fake reasons how to close it. All that I suggested 2 years ago is killing feature for Visual Code to make the app very good for all. Your company where you're working very rich and have enough resources to implement this feature. Because the feature is LAST reason why a lot of people staying on competitors editors like sublime text.

About what the issue?

About adding search exactly the same like in the Sublime Text, and many other modern editors.

What means exactly the same:

  1. Multiline search via copy-pasting text to the field
  2. Multiline and floating/agile text box what user can regulate size for inserting text there
  3. Easy searching though WHOLE opened folder for chunks of the text, and displaying USEFUL and easy to use results in the page with the founded code and where it has been founded and very easy access to the file exactly to the line where the code is located. Sublime Text is a very good example of how it's can be implemented.
  4. Allowing to use in search fields default VSCode commands and text manipulations, like it's allowed to do Sublime Text and others editors. That means multiline cursor, multiline edit, etc.

Almost everything explained in the post, already showed on MY gif which I posted when did open the issue 2 years ago.

Because of the limitation of software what you're using for VSCode you are not able to do this functionality easy, and will not be allowed to do it in soon time at all. That why I still think that the feature will not be implemented at least for several next years. And this is my right for this opinion.

And please, do not touch title of the issue or change the content of it because of your childish nature, okay? I will not be anyhow offended if you because of your pity will close the issue, you will make problems to a lot of developers because of your emotions, and not to me.

And no, the issue is not for a single file only. The issue for all files and this is a super complex feature.

svipas commented 6 years ago

@anacondaqq Can you please be more polite? VS Code is an amazing tool because of such people like @roblourens working on it. Remember this tool is free and as it was mentioned earlier create a PR by yourself since you're paying nothing to use it with such great features. Also, it isn't very easy to do such features and they have other priorities like bugs or important features than this. Why sometimes people are so toxic I don't get it, especially in such communities like this, we should be way more polite and help each other to improve tools like this and motivate VS Code team.

rebornix commented 6 years ago

Thanks @roblourens for responding and answering questions here for me as this issue is assigned to me and we see requests here for both the search viewlet (find/replace in files) and the find widget (single file find and replacement). We already have https://github.com/Microsoft/vscode/issues/13155 to track the multiline search for the search viewlet, so renaming this issue to "single file" specific can help us track issues but we don't mean to ignore anyone's requests as #13155 and this issue cover them.

Rigrep just supports multiline search and find widget is using JavaScript's regex engine so we are able to do multiline search under the hood. IMO the challenge here is how we present the multiline find input box here, how we resize the input box and how we restore the state. We may want to have UX advice from @misolori before we start to work on a PR.

lehni commented 6 years ago

While this is important issue is receiving attention, could the layout of the search&replace UI also be reconsidered and improved, both for search / replace in one file and in all files?

Coming from Sublime Text and Atom, I was surprised by its currently rather quirky look and feel. The option buttons are tiny and rather cryptic, and so is the "Replace All" button that looks just like another option, just in a different place.

Of all the options, the "Use Exclude Settings and Ignore Files" button is the most cryptic. It's hard to tell what it does from both its image and its tooltip text, and even harder to know in which visual state it actually does what it says.

It's nice that the search has a history of previous searches (recently introduced?), but why is it not shared with the search within one file, and the search across all files?

When I search within one file, and then go to the search across multiple files, I kind of expect both to have the same most recently entered search term in the search field.

roblourens commented 6 years ago

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

garretwilson commented 6 years ago

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

@garretwilson Thats exactly what we need in vscode

hickford commented 5 years ago

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

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

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.

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

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

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

DisasterMan78 commented 5 years ago

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

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

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

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

garretwilson commented 5 years ago

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

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

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

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

Nice!

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

CRM4sA8

rebornix commented 5 years ago

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

BobSeu commented 5 years ago

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

rebornix commented 5 years ago

@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 https://github.com/microsoft/vscode/issues/79893).

anacondaq commented 5 years ago

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

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

rebornix commented 5 years ago

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