Textmate 可以将我的代码排序成可读的列吗?

Textmate 可以将我的代码排序成可读的列吗?

我喜欢缩进重复的代码行,这样它们就很容易查看并发现细微的差异。例如,这很难阅读:

address = "1800 Washington St."
name = "George McGoo"
user_type = "admin"

但这很容易阅读:

address   = "1800 Washington St."  
name      = "George McGoo"  
user_type = "admin"

有没有办法在 Textmate 中做到这一点而不磨损我的空格键?

答案1

我对 textmate 一无所知,但您可以使用命令行解决手头的问题:

$ cat addresslist 
address = "1800 Washington St."
name = "George McGoo"
user_type = "admin"

address = "1800 Washington St."
name = "George McGoo"
user_type = "admin"

$ awk -F'=' '{a[NR]=$0;l=length($1);if(l>max){max=l};last=NR}END{for(i=1;i<=last;i++){if(a[i]~/=/){c=a[i];gsub(/^[^=]+*=/,"",c);b=a[i];gsub(/=.*$/,"",b);printf "%-*s = %s\n",max,b,c}else{print a[i]}}}' addresslist
address    =  "1800 Washington St."
name       =  "George McGoo"
user_type  =  "admin"

address    =  "1800 Washington St."
name       =  "George McGoo"
user_type  =  "admin"

相关内容