perl - 如何删除 Perl::Tidy 中的前导注释空格?

标签 perl perl-tidy

我只是配置 Perl::Tidy 来匹配我的偏好。我只剩下一个问题无法解决。

示例脚本:

#!/usr/bin/perl
#   |   |   |   |   |   < "|" indicates first five "tabs" (1 tab 4 spaces).
use strict;     # Enable strict programming mode.
use warnings;   # Enable Perl warnings.
use utf8;       # This is an UTF-8 encoded script.
1;

perltidyrc:

# Perl Best Practices (plus errata) .perltidyrc file

-l=76   # Max line width is 76 cols
-i=4    # Indent level is 4 cols
-ci=4   # Continuation indent is 4 cols
-et=4   # 1 tab represent 4 cols
-st     # Output to STDOUT
-se     # Errors to STDERR
-vt=2   # Maximal vertical tightness
-cti=0  # No extra indentation for closing brackets
-pt=0   # Medium parenthesis tightness
-bt=1   # Medium brace tightness
-sbt=1  # Medium square bracket tightness
-bbt=1  # Medium block brace tightness
-nsfs   # No space before semicolons
-nolq   # Don't outdent long quoted strings
-wbb="% + - * / x != == >= <= =~ < > | & **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x="
        # Break before all operators

# extras/overrides/deviations from PBP

#--maximum-line-length=100               # be slightly more generous
--warning-output                        # Show warnings
--maximum-consecutive-blank-lines=2     # default is 1
--nohanging-side-comments               # troublesome for commented out code

-isbc   # block comments may only be indented if they have some space characters before the #

# for the up-tight folk :)
-pt=2   # High parenthesis tightness
-bt=2   # High brace tightness
-sbt=2  # High square bracket tightness

结果:

#!/usr/bin/perl
#   |   |   |   |   |   < "|" indicates first five "tabs" (1 tab 4 spaces).
use strict;      # Enable strict programming mode.
use warnings;    # Enable Perl warnings.
use utf8;        # This is an UTF-8 encoded script.
1;

正如您所看到的,有一个前导空格导致“#”与第四个选项卡不匹配。

如何删除这个前导空格?

最佳答案

Perltidy 只能更改 perl 代码,因为它知道 perl 代码的含义。评论可以包含完全任意的数据,因此 perltidy 无法触及它。所以,这种事情就得你自己解决了。

关于perl - 如何删除 Perl::Tidy 中的前导注释空格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12768797/

相关文章:

perl - 分布式测试框架

perl - 是否可以在 Perl 中使用单个文件句柄读取多个文件?

mysql - 使用 Perl DBI selectall_hashref 时出现错误 "attribute parameter is not in hash ref"

perl - 配置 Perl::Tidy 来处理自定义关键字

错误 : an option to keep sub($args){} as a single line?

perl - 如何在 perl 中堆叠函数定义(一次调用它们)?

perl - 查找 perl 污点模式错误的根源

python - 哪个 Python 最接近 Perl::Tidy?

perl - 我们如何使用 Perl::Tidy 或 Perl::Critic 捕捉旁注?