Reputation: 6362
Is there a way in Eclipse to bound a piece of code to a shortcut?
I use System.out.println() quite often, for testing and other things, and it would be so much easier if I had to press you ctrl + something instead of typing it out every time..
Upvotes: 2
Views: 127
Reputation: 59343
For System.out.println
, you can type something like:
"test"
Then highlight it, press CTRL+Space, type sysout
, and press enter.
As Pescis noted in the comments, you can also type sysout
followed by CTRL+Space. It gives you the System.out.println();
with a focus inside the brackets. (Thanks Pescis!)
To create new templates, go to Window -> Preferences -> Java -> Editor -> Templates
.
Here is a link to some ready-made templates, if you are interested.
Upvotes: 6