In Intellij IDEA how do I replace text with a new line?

前端 未结 10 1163
忘掉有多难
忘掉有多难 2020-12-24 00:00

Say I wanted to replace all commas with commas and a new line using Intellij IDEA\'s replace function. What do I put in the search box? In vim I\'d use &\\r

相关标签:
10条回答
  • On intellij Ultimate 2017.1:

    I didn't need regex. But I could make the multiline replace appear.

    • I entered \n in the field I wanted to replace
    • I placed my cursor in the field where I wanted to enter the replacement text, and clicked Ctrl-Shift + Enter. Here I just hit return

    0 讨论(0)
  • 2020-12-24 00:47

    You need to check the Regex box and use "\n" for the new line character:

    enter image description here

    0 讨论(0)
  • 2020-12-24 00:47

    The easiest way that I have done it is to use the regular expression form of replace.

    enter image description here

    Chances are that you don't want to replace the {, but just keep in my escaping them if you do want to do so.

    0 讨论(0)
  • 2020-12-24 00:49

    For those looking for the old multiline replace in inteliJ with version > 15.x. It seems somewhat hidden, but if you select multiple lines > click CTRL+F, then immediately click CTRL+R you are presented with the original multiline replace.

    This is working on Mac IntelliJ 2016.1.3 with ⌘+F > ⌘+R

    0 讨论(0)
提交回复
热议问题