Utility macros for breaking strings not working anymore in IDEA 9: how to?

Since when IDEA started supporting macros I defined two macros that I would use with keyboard shortcuts in order to break strings, so for instance of I was writing:

log.info("A customer with id| does not exist")

I could put the cursor where the | is, press ctrl-alt-' and I would get

log.info("A customer with id '" + | + "' does not exist")

and ctrl-alt-; would get

log.info("A customer with id " + | + " does not exist")

In IDEA9 this does not seem to work anymore, with various problems (in particular the " disappear).

Is there anyone having an idea about how I can get this back or obtain the same with a different mechanism?

0

I use a live template for this:

abbreviation: sp

name: split

Context: java string

content: " + $END$ + "

"String to sp| split" --> "String to " + | + " split"

The only "caveat" (found just now for the first time) is that "String tosp| split" doesn't work, as idea thinks the live template is "tosp".

0

Great tip, thanks.

0

I think this should really be a built-in action and created a bug tracker issue:
http://youtrack.jetbrains.net/issue/IDEABKL-5664
However it got moved to the backlog because it was deemed a "very narrow use case".
I still think it is a very common use case (even if narrow) and it seems other people
fell that way, too.

Feel free to vote or comment on that issue!

On 05.02.2010 23:51, Davide Baroncelli wrote:

Great tip, thanks.

>

---
Original message URL: http://www.jetbrains.net/devnet/message/5256100#5256100


0

Yes, I just have tried several variants of a keyboard macor and none worked (with sometimes very strange effects like a selection start point being set after applying the template, so that moving around with the arrow keys after applying the template changed the selection).
I don't really like the live template solution, because you can't (?) create a keyboard shortcut for a live template and typing an extra space before typing the live template name before typing "TAB" before deleting the bogus space character again is simply too much of a hassle.

Do you mind to file a Jira issue that describes explicit steps to create the macro, the expected outcome of applying it, and the faulty current behavior?
I would surely vote for that to get fixed. Other macros than this are probably affected, too.

0

请先登录再写评论。