3

I realized that "macros" - is really useful thing. But I've face with a strange its behavior.

Just after it is recorded it works OK. And after few days whitespaces disappear from it.

E.g. I've created macro(and binded hotkey) for typing <?php echo [CURSOR] ?>. After few after calling this macro only <?phpecho [CURSOR] ?> is typed.

Does anybody know why this happens? It is not a huge problem but it is a bit irritating.

Thanks in advance.

UPD @LazyOne:

No, it is not the same thing. It is not handy for me to use live templates instead of macros.

If I use live template to type <?php echo [CURSOR] ?> I'm to type, e.g. e->c->o->TAB(or any other unique char sequence(!))

If I use macro I type Ctrl+Shift+E(If I bind hotkey). Much more easy as for me to press three key at the same time instead 4 keys sequentially.

It is the only one thing which stops me to use live templates.

If it were possible to call live template by hotkey it would be great. As far as I know it is impossible.

Ruslan Polutsygan
  • 4,401
  • 2
  • 26
  • 37
  • 2
    Why do you use "macros" for this? There is such thing in PhpStorm called **Live Templates** (check in Settings) -- that's what you should use instead. Or ... maybe it is the same thing we are talking about? – LazyOne Oct 09 '12 at 12:54
  • @RuslanPolutsygan, you can assign a shortcut to live template as described in [my answer here](http://stackoverflow.com/a/9639266/104891). – CrazyCoder Oct 09 '12 at 13:39
  • @RuslanPolutsygan, lost spaces is a bug which should be fixed in IDEA 12. See the [related issue](http://youtrack.jetbrains.com/issue/OC-967). – CrazyCoder Oct 09 '12 at 13:46
  • @CrazyCoder: http://stackoverflow.com/a/9639266/104891 - spaces are still lost. Anyway, thanks. What version of IDEA PhpStrom based on? PhpStorm 5.0. When is IDEA 12's release being expected? – Ruslan Polutsygan Oct 09 '12 at 14:23
  • @RuslanPolutsygan, what spaces? You configure a live template, then a macro without spaces to expand it, then assign shortcut to a macro. Do you mean that spaces in live template are lost when you expand the live template? If you have it in PhpStorm 5.0, it's worth submitting a new issue as it's probably another bug that is not fixed yet. – CrazyCoder Oct 09 '12 at 14:29
  • @CrazyCoder, sorry, I was overtired yesterday and must have done something wrong. It works. And I believe it worked yesterday. I you want you may post an answer and I'll accept it. Thank you. – Ruslan Polutsygan Oct 10 '12 at 06:14
  • Live Templates are not macros. Anyone who has used real macros understands that Live Templates are quite limited compared to macros. Being able to record macros is a step in the right direction, but not being able to edit the recorded macro is a severe limitation, since any error during the recording means re-recording the macro. I often end up writing a PHP script to perform the operations instead of recording a macro. Then I can edit the script to correct errors and improve the process. – Bob Ray Dec 27 '21 at 05:05

1 Answers1

3

There is a workaround described in my other answer. You can create a live template, then record a macro expanding this template and then assign a keyboard shortcut to a macro.

Removing spaces in macros seems to be a bug that is worth reporting if you have a test case.

Community
  • 1
  • 1
CrazyCoder
  • 389,263
  • 172
  • 990
  • 904