如何防止PerlTidy对齐分配但继续添加单个空格?

时间:2010-12-27 10:58:48

标签: perl perl-tidy

如何防止PerlTidy对齐分配但继续添加单个空格?

这个问题与How can I prevent PerlTidy from aligning my assignments?类似,但我希望在指示的地方添加单个空格。由于此-naws开关对我不起作用。我只是不想插入多个空格。可能与perltidy或其他工具有关吗?

Perl整洁的变化:

my $a    = 1;
my $aa = 2;
my $aaa= 3;

my $a   = 1;
my $aa  = 2;
my $aaa = 3;

与-naws保持不变:

my $a    = 1;
my $aa = 2;
my $aaa= 3;

我希望将此代码格式化为:

my $a = 1;
my $aa = 2;
my $aaa = 3;

1 个答案:

答案 0 :(得分:3)

以下补丁对我有用:

--- Tidy.pm.org 2009-06-16 22:00:50.000000000 +0200
+++ Tidy.pm 2010-12-28 09:43:19.625000000 +0100
@@ -12404,7 +12404,7 @@
         # accept vertical alignment.

         # nothing to do if we aren't allowed to change whitespace
-        if ( !$rOpts_add_whitespace ) {
+        if ( 1 || !$rOpts_add_whitespace ) {
             for my $i ( 0 .. $max_index_to_go ) {
                 $matching_token_to_go[$i] = '';
             }