简体   繁体   English

Intellij IDEA 上的 System.out.println() 快捷方式

[英]System.out.println() shortcut on Intellij IDEA

I know I can print System.out.println() with "sout" + tab .我知道我可以用"sout" + tab打印System.out.println() Is there a way I can do it with "Syso" + ctrl + space like in eclipse?有没有办法像在 eclipse 中那样使用"Syso" + ctrl + space来做到这一点?

In Idea 17eap:在想法 17eap 中:

sout : Prints sout :打印

System.out.println();

soutm : Prints current class and method names to System.out soutm :将当前类和方法名称打印到 System.out

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

soutp : Prints method parameter names and values to System.out soutp :将方法参数名称和值打印到 System.out

System.out.println($FORMAT$);

soutv : Prints a value to System.out soutv :将值打印到 System.out

System.out.println("$EXPR_COPY$ = " + $EXPR$);

Yeah, you can do it.是的,你可以做到。 Just open Settings -> Live Templates.只需打开设置 -> 实时模板。 Create new one with syso as abbreviation and System.out.println($END$);新建一个以syso为缩写, System.out.println($END$); as Template text.作为模板文本。

If you want to know all the shortcut in intellij hit Ctrl + J .如果您想知道 intellij 中的所有快捷方式,请按 Ctrl + J This shows all the shortcuts.这将显示所有快捷方式。 For System.out.println() type sout and press Tab .对于System.out.println()输入sout并按Tab

Open up Settings (By default is Alt + Ctrl + S) and search for Live Templates.打开设置(默认为 Alt + Ctrl + S)并搜索实时模板。 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".在上部有一个选项,上面写着“默认使用 TAB 扩展”(TAB 是默认值),选择“自定义”,然后点击“更改”并将键映射“ctrl+空格键”添加到选项“扩展实时模板/埃米特的缩写”。

Now you can hit ctrl + spacebar and expand the live templates.现在您可以按 ctrl + 空格键并展开实时模板。 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.现在,要将其更改为“syso”而不是“sout”,在“实时模板”选项中,选中了大量选项列表,转到“其他”并展开它,您会在那里找到“sout”,只需将其重命名即可到“syso”并点击应用。

Hope this can help you.希望这可以帮助你。

在 MAC 上,您可以执行sout + return⌘+j (cmd+j) 打开实时模板建议,输入sout以选择System.out.println();

如果使用 scala,请尝试priv + tab

Type sout and press Tab , it will generate System.out.println();输入sout并按Tab ,它将生成System.out.println();

Type sou and press Tab , It will generate System.out.printf("");输入sou并按Tab ,它将生成System.out.printf("");

For MAC, if it doesn't work (command) + j after sout.对于 MAC,如果它在 sout 后不起作用(命令)+ j。 Do you know what I must do?你知道我必须做什么吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM