Reputation: 36140
I am aware of the Eclipse snippet "sysout" which is neatly replaced with System.out.println(); when tab-completed.
This is very useful but sometimes, I need to wrap some existing code in a System.out.println();
In Eclipse internals, the template is defined as being able to wrap a "selected word". But how can I use the snippet with selected text since typing "sysout" obviously removes the selected text.
Any idea?
Upvotes: 25
Views: 73423
Reputation: 153
The main part is into:
Java->Editor->Templates
This can accessed by:
Surrounding a text and press:
Windows: SHIFT + ALT + Z (as sadhasivam said)
Mac: CMD + OPT + Z
to display the Preferences Window
Upvotes: 0
Reputation: 1
Preference>General>Keys. then search "content assist" or "content" in "type filter text". don't press Enter. choice "content assist". type Binding and set your own shortcuts. such as "control+space".
Upvotes: 0
Reputation:
Eclipse has "Surround Width" Option which can do this for you.
SHIFT + ALT + Z should get you that to see how that templates meta-data layout.
Upvotes: 3
Reputation: 39495
if you use content assist (ctrl-space on Windows), at the end of the list will be the sysout option. you might want to augment the template with quotes around the word selection so you dont need to type them in.
Upvotes: 0
Reputation: 11230
The sysout template acts upon entire Java statements.
System.out.println
when you hit enter.)Upvotes: 71
Reputation: 829
I don't think you can do it in one go, but what about cutting the selected text and then: tab+space, ctrl+v it's just one key combination more.
Upvotes: 0