Tomasz Waszczyk
Tomasz Waszczyk

Reputation: 3159

"syso" shortcut in Eclipse- changing a bit behaviour

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 !

Upvotes: 4

Views: 62135

Answers (3)

Rafael Membrives
Rafael Membrives

Reputation: 644

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.

Upvotes: 2

MelodiC_ChaotiC
MelodiC_ChaotiC

Reputation: 53

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.

Upvotes: 1

Naveen Kumar Alone
Naveen Kumar Alone

Reputation: 7678

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.

Upvotes: 6

Related Questions