240

I know I can print System.out.println() with "sout" + tab. Is there a way I can do it with "Syso" + ctrl + space like in eclipse?

Paolo Forgia
  • 6,572
  • 8
  • 46
  • 58
m.rossi
  • 2,602
  • 2
  • 12
  • 13

7 Answers7

334

In Idea 17eap:

sout: Prints

System.out.println();

soutm: Prints current class and method names to System.out

System.out.println("$CLASS_NAME$.$METHOD_NAME$");

soutp: Prints method parameter names and values to System.out

System.out.println($FORMAT$);

soutv: Prints a value to System.out

System.out.println("$EXPR_COPY$ = " + $EXPR$);
yunandtidus
  • 3,847
  • 3
  • 29
  • 42
Olga
  • 3,705
  • 1
  • 20
  • 23
  • Is there any shortcut to call soutm for all functions in a file in one go? This is useful when you want to trace the function call flow with the help of logs. – nkalra0123 Jun 05 '19 at 08:56
  • 6
    Irrelevant answer regarding to question – Payel Senapati Jan 02 '21 at 18:13
  • One important thing to highlight is that Don't start with capital `S`. It should be small 's' then code suggestion will actually suggest `sout` which on selection will do it. – nanosoft Jun 07 '21 at 05:58
68

Yeah, you can do it. Just open Settings -> Live Templates. Create new one with syso as abbreviation and System.out.println($END$); as Template text.

Konstantin Labun
  • 3,688
  • 24
  • 24
  • 4
    This does not answer his wish to auto complete with ctrl+space. – Murat Karagöz Aug 17 '16 at 09:01
  • Well, if he makes this setting, can't he just type `syso` and press `Tab` to complete the statement? We do something similar while defining the main method: we type in `psvm` and press `Tab` which automatically makes it `public static void main(String[] args)`. – progyammer Aug 17 '16 at 09:04
  • ctrl+space expands live templates as well – Peter Gromov Aug 17 '16 at 09:25
  • 2
    ctrl+space does not expand sout the same way tab does, it pulls up a menu with sout listed in it though--so pretty close (And that may be only because I turned on the Eclipse keymap). Leo's answer helps – Bill K Jan 19 '18 at 00:27
  • 1
    Along with this answer, make sure you select the below, "Applicable in Java: statement" by making the selection in the dropdown. Also, the Shortcut to use Eclipse shortcuts in IntelliJ Idea, follow the below steps https://stackoverflow.com/a/59934543/3253199 Shortcut to use Eclipse shortcuts in IntelliJ Idea: Press ctrl+`(also have tilde~ on it, button at the left side of digit 1). Then press 3 (Keymap) and select 2 (Eclipse). Done! – Sreedhar S Jan 10 '21 at 21:59
  • I added soup as the shortcut in live template in Java context, for System.out.print($END$); – Tuhin Mitra Apr 25 '21 at 07:52
55

If you want to know all the shortcut in intellij hit Ctrl + J. This shows all the shortcuts. For System.out.println() type sout and press Tab.

Kristijan Iliev
  • 4,901
  • 10
  • 28
  • 47
15

Open up Settings (By default is Alt + Ctrl + S) and search for Live Templates. In the upper part there's an option that says "By default expand with TAB" (TAB is the default), choose "Custom" and then hit "change" and add the keymap "ctrl+spacebar" to the option "Expand Live Template/Emmet Abbreviation".

Now you can hit ctrl + spacebar and expand the live templates. Now, to change it to "syso" instead of "sout", in the Live Templates option, theres a list of tons of options checked, go to "other" and expand it, there you wil find "sout", just rename it to "syso" and hit aply.

Hope this can help you.

Leo
  • 472
  • 5
  • 9
5

Type sout and press Tab, it will generate System.out.println();

Type sou and press Tab, It will generate System.out.printf("");

Supun Sandaruwan
  • 1,814
  • 19
  • 19
4

On MAC you can do sout + return or ⌘+j (cmd+j) opens live template suggestions, enter sout to choose System.out.println();

MrKulli
  • 735
  • 10
  • 19
3

If using scala, try priv + tab

Oleg Svechkarenko
  • 2,508
  • 25
  • 30
Janac Meena
  • 3,203
  • 35
  • 32