Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace string in Eclipse with newline in replacement

Tags:

java

eclipse

Of course this question can be googled - however most of the hits are very old and don't seem to apply in Eclipse Mars.

I simply want to replace a line with a multiline replacement. There must be some way to do this, but I can't seem to find anything that works.

replace

import a.b.c.d;

with

import e.f.g.h;
import i.j.k.l;
like image 629
Steve Cohen Avatar asked Aug 08 '16 17:08

Steve Cohen


People also ask

How do I add a line break in eclipse?

1. Find all with "public" and change to "\npublic", \n being the new line in a string to give you the idea of what I mean. 2. A convenient eclipse shortcut that separates all the methods in a class with an empty line.

How do you replace something in eclipse?

This Eclipse plugin enhances any editor in Eclipse with a Find/Replace dialog that can be brought up with Ctrl + F5.


1 Answers

First you need check "Regular expressions" Then simply add \R between line. For example Ctrl+F, select "Regular expressions" "Find" box you put : import a.b.c.d; "Replace with" box you put : import e.f.g.h;\Rimport i.j.k.l; Then it will been replaced and separate line as you want.

like image 130
Semicolon Avatar answered Oct 17 '22 05:10

Semicolon