Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ IDEA Vim emulator's regex behaviour with newlines

For example, to transform:

List(
  User(1)

into:

UserQuery ++= List(
  User(1)

where the User is matched and used in forming UserQuery.

I've had some difficulty getting newlines in regex to work with IntelliJ's Vim emulator (at the bottom of the editor window, after pressing and :). There's no ^v like in ordinary Vim. :/

IntelliJ IDEA version: 14.1.3 (first time I've tried this in IntelliJ IDEA and so I don't know if this is a new issue.) Platform: Mac OS X 10.10.2 (Yosemite)

like image 670
bjfletcher Avatar asked Jun 06 '15 22:06

bjfletcher


1 Answers

I've found the following to work.

To match: use \n. To substitute in: use \r.

That is, \n doesn't work in substitution, \r doesn't work in pattern. This regex works:

s/List(\n\( *\)\(\w*\)/\2Query ++= List(\r\1\2/
like image 188
bjfletcher Avatar answered Oct 23 '22 11:10

bjfletcher