我在Perl中有一个子程序,应该像这样缩进:
sub GetFiles { my $pwd = shift; my @input = @_; my @returned; my @DirectoryContent = &GetContentInformation(@input); foreach (@DirectoryContent) { my %current = %{$_}; if ($current{'info'} =~ /<DIR>/) { my $RecurseDir = &GetRecurseDir($pwd,\%current); push(@returned,&GetFiles($RecurseDir,&GetDirectoryContents($RecurseDir))); } else { # clean up the data my $size = $current{'info'}; # filesize will be in number of bytes # remove file separators #$size =~ s/,//g; my $extension = &GetFileExtension($current{'name'}); delete($current{'info'}); $current{'size'} = $size; $current{'extension'} = $extension; # push(@returned,\%current); } } @returned; }
但是当我按下子程序块的起始括号上的=%(是的,cindent打开)时,它会像下面那样缩进:
sub GetFiles { my $pwd = shift; my @input = @_; my @returned; my @DirectoryContent = &GetContentInformation(@input); foreach (@DirectoryContent) { my %current = %{$_}; if ($current{'info'} =~ /<DIR>/) { my $RecurseDir = &GetRecurseDir($pwd,\%current); push(@returned,&GetDirectoryContents($RecurseDir))); } else { # clean up the data my $size = $current{'info'}; # filesize will be in number of bytes # remove file separators #$size =~ s/,//g; my $extension = &GetFileExtension($current{'name'}); delete($current{'info'}); $current{'size'} = $size; $current{'extension'} = $extension; # push(@returned,\%current); } } @returned; }
为什么这样做?我该如何解决?
编辑:应该注意我在Windows上使用gvim 7.3.
也许这是神奇的想法,但是…我曾经有过:
原文链接:https://www.f2er.com/bash/384188.htmlfiletype plugin on filetype indent on
在我的_vimrc中(在Windows XP上,自编译的gvim,各种版本),我会在Perl,LaTeX和HTML文件中得到各种有趣的缩进问题.
我现在有
filetype indent on filetype plugin on
而且一切似乎都是笨拙的.因人而异.
另外,我强烈推荐Andy Lester’s vim-perl.