Karlovsky120
Karlovsky120

Reputation: 6362

Add piece of code to shortcut

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

Answers (2)

tckmn
tckmn

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

Achintya Jha
Achintya Jha

Reputation: 12843

Type syso and ctrl + space for System.out.println()

Upvotes: 0

Related Questions