0

I was wondering whether there was a function in KDevelop similar to the one that we used to have in Quanta (miss you, Quanta, btw).

I would like to set a keyboard shortcut, and apply a text transformation upon hitting it. Example:

I select my text to be translated, and I get back: <?=_('my text to be translated'?> As you can see, this saves me a lot of awkward keystrokes...

I only found this feature in PHPStorm (where it is called "Live Templates"). I defined it like this: <?=t('$SELECTION$')?> and I can call it by hitting CTRL+ALT+J, and select it from the dropdown that appears.

Palantir
  • 23,820
  • 10
  • 76
  • 86
  • 1
    "software tools commonly used by programmers" is a bullet point on the [on-topic list](http://stackoverflow.com/help/on-topic) of the [help]. An IDE is such a tool. This question is on topic here. – Oded Feb 10 '14 at 14:40
  • Oops. Sorry about that. I just re-read the on-topic list :) – Palantir Feb 10 '14 at 14:41
  • No problem. Common misconception - for some reason people think that library, IDE and build questions don't belong here when they do. – Oded Feb 10 '14 at 14:42

1 Answers1

1

You should be able to do that using a snippet with the following text: <?=_('%{selection}'?>

And you can bind a Shortcut to a snippet.

However my tests showed that this doesn't work correctly - there seems to be a bug somewhere.

As alternative you can write a script that does insert the text. See the documentation.

Niko Sams
  • 4,304
  • 3
  • 25
  • 44
  • Thanks for the reply, I was not aware of the snippets plugin before. It is promising, but you are right, looks like there is a bug in it because I too get unexpected results... Looks I am out of luck :\ – Palantir Feb 13 '14 at 09:54