简体   繁体   English

WebStorm PhpStorm代码重新格式化:如何修复注释?

[英]WebStorm PhpStorm code reformat: how to fix comments?

WebStorm and PhpStorm allow you to reformat your code to fit the coding style set in settings (eg: indentation space) WebStorm和PhpStorm允许您重新格式化代码以适应设置中设置的编码样式(例如:缩进空间)

I'm using this measure to fix some of the many lint errors in my project but I'm stuck at one point: is it possible to reformat all // comments to begin with a space? 我正在使用这个措施修复我的项目中的许多lint错误,但我仍然坚持一点:是否有可能重新格式化所有//注释以空格开头? To go from 来自

//My comment

to

// My comment

If a comment already begins with a space character, it should be left alone. 如果评论已经以空格字符开头,则应该单独留下。

Edit: There is an option in: 编辑:有一个选项:

  • "Settings >> Editor >> Code Style >> {{coding lang}} >> Other tab" to set a blank space at the start of each comment (see " Comment code " section at the bottom of this image). “设置>>编辑器>>代码样式>> {{coding lang}} >>其他选项卡”在每个注释的开头设置一个空格(参见本图底部的“ 注释代码 ”部分)。

在此输入图像描述

However, even with that selected, using the "Reformat code" option does not fix the comments. 但是,即使选择了该选项,使用“重新格式化代码”选项也无法修复注释。

'Add a space at comment start' option only affects 'Comment with line comment' action ( Ctrl+/ ) behavior, it is not used by formatter. “在评论开始时添加空格”选项仅影响“评论与行注释”操作( Ctrl+/ )行为,格式化程序不会使用它。

There is currently no way to insert leading spaces on formatting, please vote for WEB-26244 目前无法在格式化中插入前导空格,请投票支持WEB-26244

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

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