简体   繁体   中英

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)

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM