views:

69

answers:

1

Hello !

Today I have question about Eclipse. I use this IDE very long and I think it is good, but last time I miss for some functionalities...

Is it possible to set some shortcut which will do something like:

Mark some text ('Hello world'), trigger shortcut (Ctrl+T) and it will do something with that text - in example adds text before and after selected text ($this->_('Hello world'))

?

Thanks for any sugestion !

+1  A: 

From this, it appears you have to implement your own command in a plugin. The process looks more involved than simply setting a menu choice.


Equivalent functionality can be defined without commands, if you're willing to give up the keyboard shortcut and use content assist instead.

I'm not sure if it will work with the language you're using (PHP?), but with Java in Eclipse it is possible to use Code Templates.

You would define your own template, when it was applicable and what it would do. This could then be accessed with Ctrl+Space through the possible content assist methods. So in the context of Java statements, I can define:

this.call(${word_selection});

So when I highlight a word, such as "Hello, world", I can use the template to change it to:

this.call("Hello, world");

(There are ways to limit it to only String types instead of word selections, but that will most likely not apply to your language, so I didn't pursue exactly how to do it.)

The Code Templates menu is available through Window->Preferences.

Grundlefleck
Thanks for the answer ! I know about `Code Templates` very well - very helpful. ;) But I am looking for some way to do it with shortcuts.
hsz
From a cursory glance at Preferences->General->Keys, it looks as if you can't define your own commands for shortcuts. You may be out of luck :(
Grundlefleck