Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 338063

Summary: Eclipse Should support multiple line replace operations
Product: [Eclipse Project] Platform Reporter: Martin Oberhuber <mober.at+eclipse>
Component: SearchAssignee: Platform-Search-Inbox <platform-search-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: enhancement    
Priority: P3 CC: daniel_megert, deepakazad, eclipse, katalonec, lars.sonchocky-helldorf, lpm_eclipse, markus.kell.r, martinae, mirko.novakovic, mrgcohen, mschorn.eclipse, pedbessa, sanjay.madhavan, stephan.bachofen, stepper, xavier.mehaut, yevshif
Version: 3.6.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug
Bug Depends on: 26780    
Bug Blocks:    
Attachments:
Description Flags
Screenshot of UI for multi-line replacement none

Description Martin Oberhuber CLA 2011-02-24 05:37:35 EST
Created attachment 189683 [details]
Screenshot of UI for multi-line replacement

+++ This bug was initially created as a clone of Bug #26780 +++

As an Eclipse IDE user, I want to search & replace multiple lines of text, eg in order to update file copyright headers to incorporate a new licensing scheme.

As of Eclipse 3.6.1, the following works nicely for multi-line search:

  1. Search > File... , enable the "Regular Expression" checkbox, cancel
  2. In an editor, make a multi-line selection
  3. Press Ctrl+H, Search
  --> Multi-line selection is searched (and may be replaced by a single line).

But I found no way getting a multi-line replacement done.

One idea for supporting this would be a little "Edit Text" icon right to the replacement combo. Clicking that "Edit Text" icon could open a dialog with a multi-line text field for entering (or pasting) the multi-line replacement. Pressing OK would convert that multi-line replacement into something suitable for the single-line combo. See attached screenshot for how we do this in our commercial Eclipse-based product which has its own text search UI.

Or, pasting a multi-line selection into the combo could directly convert it into something suitable.
Comment 1 Dani Megert CLA 2011-02-24 05:55:42 EST
>But I found no way getting a multi-line replacement done.
Add the text into the replace field manually:
line1\R\line2\line3....
Comment 2 Dani Megert CLA 2011-02-24 06:00:34 EST
>line1\R\line2\line3....
Of course:
line1\Rline2\Rline3....
Comment 3 M CLA 2011-03-27 15:44:39 EDT
The following will search multiline, where test could be on line 1 and test 5 on line 20. Of course it's very possibly this recursion will crash eclipse. 

test(\R|.*?)*test5

(In reply to comment #2)
> >line1\R\line2\line3....
> Of course:
> line1\Rline2\Rline3....
Comment 4 Markus Keller CLA 2011-04-01 11:25:28 EDT
(In reply to comment #3)
This bug is about multi-line *replace*, not search.

> The following will search multiline, where test could be on line 1 and test 5
> on line 20. Of course it's very possibly this recursion will crash eclipse. 
> 
> test(\R|.*?)*test5

Nested repetition expressions are inherently inefficient. The right way to have "." match line delimiters is to enable single-line mode like this: "(?s)test.*test5"  (press Ctrl+Space after "(?" to read the description)
Comment 5 Lars Vogel CLA 2019-11-14 02:18:03 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

If the bug is still relevant, please remove the "stalebug" whiteboard tag.