本文介绍了如何防止PerlTidy对齐分配,但继续添加单个空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How can I prevent PerlTidy from aligning assignments but keep adding single spaces?

此问题类似于如何防止PerlTidy对齐我的作业?,但我希望在定向的位置添加单个空格.由于此-naws开关对我不起作用.我只是不想插入多个空格.可能是完美的或其他工具吗?

This question is similar to How can I prevent PerlTidy from aligning my assignments? but I would like single spaces to be added where directed. Due to this -naws switch does not work for me. I just do not want multiple spaces to be inserted. Is it possibe with perltidy or some other tool?

Perl的整洁更改:

Perl tidy changes:

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

进入

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

使用-naws时,它保持不变:

with -naws it remains unchanged:

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

我希望此代码的格式为:

I would like this code to be formatted as:

my $a = 1;
my $aa = 2;
my $aaa = 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] = '';
             }

这篇关于如何防止PerlTidy对齐分配,但继续添加单个空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 23:47