Intellij: add space after double slashes in line comment

和自甴很熟 提交于 2020-01-12 02:50:11

问题


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:

If I enter :

//This is a comment

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

// This is a comment

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


回答1:


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

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.

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

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*/


来源:https://stackoverflow.com/questions/24840544/intellij-add-space-after-double-slashes-in-line-comment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!