Search code examples
intellij-ideapycharm

How to wrap multiple lines with quotes each?


This question is the same as this one which has an accepted answer that doesn't solve the problem. I have:

line1
line2
line3

and the desired result is:

'line1'
'line2'
'line3'

The issue is not solved with multiple cursors as for more than 2 lines, it would require too much work to place n * 2 cursors around n lines which is exactly what I'm trying to avoid. The suggested solution in the question mentioned earlier is to write a plugin in Java that achieves the desired outcome which I regard as an overkill and I'm certain there are built-in features that would achieve the same thing.


Solution

  • It seems like a regex search and replace may work here, if you don't need to use this too often. Enable the In Selection option (and the Regex option of course) and search for (^.*$), and replace with '$1'.