Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the "sysout" snippet in Eclipse with selected text?

Tags:

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?

like image 738
Vincent Robert Avatar asked Jun 19 '09 21:06

Vincent Robert


People also ask

How do I Sysout in Eclipse?

To get System. out. println() line in eclipse without typing the whole line type sysout and press Ctrl + space.

How do I use Sysout shortcut?

Just type "sysout" in your Java editor and press Ctrl + space, which triggers code completion. This will expand sysout into System. out.

How do I autofill Sysout in Eclipse?

You can type syso and press ctrl + space to autocomplete it.

Why Sysout is not working in Eclipse?

So, here's what you should do: Go to Windows->Preferences->Content Assist->Advanced. Check on the box saying- Java Proposals. Uncheck the box saying- Java Proposals (Code Recommenders).


1 Answers

The sysout template acts upon entire Java statements.

  1. Highlight a statement in the editor.
  2. Hit CTRL-SPACE (or whatever you have set up for content assist.)
  3. Type sysout then hit enter. Note that when you're typing sysout it will temporarily overwrite your statement (but it will come back wrapped by System.out.println when you hit enter.)
like image 191
jimr Avatar answered Oct 08 '22 20:10

jimr