Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search and replace 2 lines (together) in Eclipse?

I would like to search multiple files via eclipse for the following 2 lines:

@Length(max = L_255) private String description; 

and replace them with these two:

@Length(max = L_255, message="{validator.description.len}") private String description; 
like image 533
Sam Avatar asked Jul 02 '10 09:07

Sam


People also ask

How do I change multiple lines in eclipse?

Press alt + shift + A to Toggle block selection (Toggle block / column selection in the current text editor), this will let you write vertically in eclipse, then you can easily do this.

How do I find and replace multiple lines?

CHANGE: The default keyboard shortcut for “Multiline Find/Replace” was Ctrl+Alt+F but it was not applied because this shortcut was already taken by “F# Interactive”. So, the new default shortcut is Ctrl+M, Ctrl+F.

How do I replace a string in an entire project in eclipse?

1 Answer. Show activity on this post. Search->File menu (also accessible using Ctrl+H , then navigate to File tab), enter the text to search for, hit the Replace... button which will give you another dialog where you can replace text.


1 Answers

Another tip on how to get the regex for a selected block. Open one of the files that contains the multiple lines (multiline) to search or replace. Click Ctrl+F and select "Regular expression". Close the Find/Replace window. Select the block you need and click again Ctrl+F to open the Find/Replace window. Now in the Find text box you have the regular expression that exactly matches your selection block.

(I discovered this, only after creating manually a regexp for very long block :)

like image 108
Mario Balaban Avatar answered Sep 20 '22 09:09

Mario Balaban