Copy the highlighted text and change it to something else
Let's say I have a text in my code.
`<input placeholder="Email Address">`
When I highlight Email Address and click a shortcut that I defined, I want 2 things:
1. Copy the "Email Address" to be copied in my clipboard
2. Turn it into `{{ trans.get('Email Address') }}` so the outcome becomes `<input placeholder="{{ trans.get('Email Address') }}">`
I couldn't figure out how to achieve it? I checked Editor External Tools but couldn't figure out if that's what I need.
----
As a bonus step, it can check a json file in a specified directory, check if string is added as json key, if not, add it there
Only if I learn the terminology for it, or a source that I can read about it, I think I'd figure it out - but full example is highly appreciated :)
Please sign in to leave a comment.
For example, you may want to use a combination of Live Templates + Macros features.
You could create a surround Live Template (with $SELECTION$ variable) to alter your selected piece of code. Then you may record a macro that will copy the selection in the clipboard and apply surround Live Template over it.
I tried it and seems to be it should work fine for your scenario.
Here is the article about Live Templates in PhpStorm:
https://www.jetbrains.com/help/phpstorm/creating-and-editing-live-templates.html