0

I want to insert another line after each occurrence of a searched line. Like, I have 50+ JSON files with lines like:

(\s)+Line1\n

I want to replace it with same indentation like:

(\s)+Line1\n
(\s)+Line2\n

How to do it in Intellij community version?(2019.2)

WesternGun
  • 9,320
  • 72
  • 124
  • Maybe you should try some command line tools like `sed`. see this answer: https://stackoverflow.com/questions/10445934/change-multiple-files – Kevin Oct 23 '19 at 16:45

1 Answers1

1

Use replace in path (under edit->find). The replace string can span multiple lines. Press ctrl-shift-enter to enter a new line in the replacement string text box. However the new string will be a fixed string and won't necessarily have the same indent as the original string. For this you will have to auto format the files.

matt helliwell
  • 2,353
  • 17
  • 24
  • Actuall at last I end with something like you said: replace without format and then select the folder and Ctrl+Alt+F to auto-format. Thanks for the tip of new line in replace box. – WesternGun Oct 24 '19 at 08:15