4

I look for some trick which gives me possibility to change the syso behaviour in Eclipse (please assume that below there is Eclipse´s editor), now it works in this way:

syso%someVariable

% - means the plase when i typed ctrl + space, and result is:

System.out.println();someVariable

but I want to have of course without copying text..:

System.out.println(someVariable);

Any hints ? :-) Thanks in advance !

2
  • I don't think, but the similar thing would be like this System.out.println(${var})
    – user2511414
    Commented Oct 31, 2013 at 14:01
  • You have to write your own template for sysout and add it to the eclipse Commented Oct 31, 2013 at 14:02

3 Answers 3

6

Reference

The feature is called "code templates" in Eclipse. You can add templates with Preferences->Java->Editor->Templates. Two good articles:

Also, this SO question:

System.out.println() is already mapped to sysout, so you may save time by learning a few of the existing templates first.

2

If you wan´t to change current template you can press shift + end (to select 'someVariable') and then press ctrl + space and up, enter to select sysout.

1

Answering the original question or at least how I understood it:

Modify the existing template syntax for sysout (Preferences->Java->Editor->Templates find sysout and select edit) to read:

System.out.println(${cursor});

Now you can type syso and then ctr+space and instantly get the output:

System.out.println(<cursorHere>);

Or as you put it:

System.out.println(someVariable);

...with the cursor inside the brackets which is indeed more efficient than starting after the semicolon.

Not the answer you're looking for? Browse other questions tagged or ask your own question.