"syso" shortcut in Eclipse- changing a bit behaviour

53,585

Solution 1

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.

Solution 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.

Solution 3

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.

Share:
53,585
Tomasz Waszczyk
Author by

Tomasz Waszczyk

Please, "write/debug-my-code", "recommend/search-something-for-me", "tutorial" requests and "low-effort", "unclear", "opinion-based" questions are Off-Topic for Stack Overflow. Good questions instead, as described in How to Ask, have research effort, a clear explanation of the problem and should include a Minimal, Complete, and Verifiable example to be useful to future visitors. Founder of Silesia Blockchain Meetup https://meetup.com/Silesia-Blockchain-Meetup/ https://mattgemmell.com/what-have-you-tried/

Updated on July 09, 2022

Comments

  • Tomasz Waszczyk
    Tomasz Waszczyk almost 2 years

    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 !