Replace selected text with processed text macro/script?

Answered

Hello,

I have multiple documents where I have to find specific strings (manually, according to my interpretation) and replace them with processed strings. Example:

<p>this is a short test string</p>

I will select "short text string" and I want it converted to

<p>this is a <?php $lang->item("short_text_string") ?></p>

(the script should replace spaces with "_", lowercase, add some text before and after, etc)

How should I approach this? In other IDEs I used some sort of macros, but they don't seem to work that well in PHPStorm (try it and you'll find out how you cannot apply replace and lowercase consecutively)

Thanks!

Marc

0
1 comment

Use the Surround live templates that work with $SELECTION$: https://www.jetbrains.com/help/idea/template-variables.html#pdtv.

For more advanced stuff there is groovyScript function inside the template that can work with the selected fragment.

0

Please sign in to leave a comment.