在IDEA中,我可以输入sout
来表示System.out.println();
并且我想知道如何制作自己的代码缩写。例如,将 System.out.print();
别名为 soun
或任何其他名称
最佳答案
这在 IntelliJ 中称为实时模板。
转到文件
> 设置
> 编辑器
> 实时模板
。从那里选择 Java,您将在右侧看到一个加号。单击它,您将得到一个 1。实时模板
,这将为您提供一个新的缩写。
将其命名为soun
,文本应为
System.out.print($END$);
完成后,请确保您已通过单击旁边的复选框启用该缩写。
docs of IntelliJ详细介绍这些模板的语法。
The
$END$
syntax indicates the position of the cursor when the code snippet is complete, and you can no longer press Tab to jump to the next variable.
还有更多变量需要考虑,other configurations要做!
编辑:有一个答案 here对于这个问题,但看起来它不一定回答该帖子中提出的问题,所以这就是为什么我决定发布一个专门的答案(解决手头的问题)。
关于intellij-idea - 如何在intellij idea中制作自己的代码缩写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66982661/