Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace string with newline PHPStorm

I cannot find a way to replace a string with a newline in PHPStorm. Anybody has ideas? Tried \n but it will just add the 2 characters instead of inserting a newline character. Additional data following SolarBear answer Here is the use case:

Original text:

"aaaaa","bbbbb","CCC", some other text 

Desired text

"aaaaa"=>"iiii", "bbbbb"=>"iiii", "CCC"=>"iiii", 

some other text

When I try SolarBear solution, I select the "aaaa" line and select multiline, and have

, 

in the top box and

 =>"iiii", [newline] 

in the second box. What happens is that the first "," is replaced, but curiously when I hit replace next "," PHPStorm replaces again the same "," Here is the output after hitting the replace button:

"aaaaa"=>"iiii"=>"iiii",  "bbbbb","CCCC" 
like image 542
Breiz Avatar asked Oct 27 '14 20:10

Breiz


People also ask

How do you replace N with a new line?

So: Press CTRL-h and the Replace dialog will open. Type \r\n in "Find what" and \\r\\n in "Replace with". Then select search mode Extended (\r, \n, \t, \x..., \0) and click "Replace All".

How to search in PhpStorm?

From the main menu, select Edit | Find | Find in Files Ctrl+Shift+F . In the search field, type your search string. Alternatively, in the editor, highlight the string you want to find and press Ctrl+Shift+F . PhpStorm places the highlighted string into the search field.


1 Answers

  • Search for: ,
  • Replace by: =>"iiii",\n
  • DO NOT FORGET to check Regex option (as shown on 1st screenshot below)
  • Hit "Replace all" button

BEFORE: enter image description here

AFTER: enter image description here

like image 120
LazyOne Avatar answered Sep 21 '22 18:09

LazyOne