Intellij:在行注释中的双斜杠后添加空格 [英] Intellij: add space after double slashes in line comment

查看:1407
本文介绍了Intellij:在行注释中的双斜杠后添加空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Intellij IDEA(我使用的是版本13)是否有一种方法可以自动为两个斜杠和文本之间的行注释添加空格:

Is there a way in Intellij IDEA (I'm using version 13) to automatically add a space to line comments between the two slashes and the text:

如果我输入:


//这是一条评论

//This is a comment

我想在运行代码重新格式化时(Windows上的Ctrl-Alt-L)获得以下内容

I'd like to get the following when I run a code reformat (Ctrl-Alt-L on Windows)


/ /这是一个评论

// This is a comment

它适用于Javascript文件,但应该适用于其他文件类型。

It's for Javascript files but should be working for other file types.

推荐答案

如果按 CTRL / CMD / 它会在行的开头加上 // ,评论将正确缩进。

If you press CTRL / or CMD / it will put // at the beginning of the line and the comment will be properly indented.

//        comment with two indents

为此工作第一栏的评论必须在编辑 - > CodeStyle-> Javascript-> Wrapping and Braces-> Keep中检查当重新格式化时,如另一个答案所述。

For this to work Comment at first column must be checked in Editor->CodeStyle->Javascript->Wrapping and Braces->Keep when reformatting like mentioned in another answer.


此截图适用于Java,但它适用于Javascript。只需在菜单中选择javascript

This screenshot is for Java, but it works the same for Javascript. Just choose javascript in the menu

如果你想写多行注释,你可以使用 CTRL SHIFT / CMD SHIFT / 当你进入新行时,你会在评论开始后有一个空格

If you want to write multiline comment you can use CTRL SHIFT / or CMD SHIFT / That way when you go into new line, you will have one space after the comment start

    /*
    * there is space before this*/

这篇关于Intellij:在行注释中的双斜杠后添加空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆