为什么vim缩进我的Perl代码?
发布时间:2020-12-16 01:16:53 所属栏目:安全 来源:网络整理
导读:我在Perl中有一个子程序,应该像这样缩进: sub GetFiles { my $pwd = shift; my @input = @_; my @returned; my @DirectoryContent = GetContentInformation(@input); foreach (@DirectoryContent) { my %current = %{$_}; if ($current{'info'} =~ /DIR/) {
我在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.
也许这是神奇的想法,但是…我曾经有过:
filetype plugin on filetype indent on 在我的_vimrc中(在Windows XP上,自编译的gvim,各种版本),我会在Perl,LaTeX和HTML文件中得到各种有趣的缩进问题. 我现在有 filetype indent on filetype plugin on 而且一切似乎都是笨拙的.因人而异. 另外,我强烈推荐Andy Lester’s vim-perl. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |