Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Macro to replace/encapsulate text in PhpStorm/IntelliJ?

For example I have the text login and I want to wrap in in a function call like {{ __('login') }} by just selecting the text and hitting a key combination to perform the change for me, speeding up my work flow.

Is there a way of doing this with PhpStorm/IntelliJ?

like image 869
Peter Fox Avatar asked Mar 25 '26 14:03

Peter Fox


1 Answers

Thanks to @LazyOne for providing info; i want to expand according to your question.

your template text will be as following if you want to surround texts like login;

{{ __('$SELECTION$') }}$END$

or if you want surround texts like 'login'

{{ __($SELECTION$) }}$END$

After you finalize your live template by selecting applicable context, it will be ready to use. When you type and select login, then hit cmd + alt + j it will surround.

Another option would be creating a live template which will print everything in the template but you fill login.

{{ __('$NAME$') }}$END$

like image 156
Ersoy Avatar answered Mar 27 '26 06:03

Ersoy