4

统计自己的Vim脚本行数

 3 years ago
source link: https://blog.lilydjwg.me/posts/17353.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

统计自己的Vim脚本行数

本文来自依云's Blog,转载请注明。

一行 zsh 命令搞定:

grep -l "Author.*`whoami`" ~/.vim/**/*[^~](.^@)|while read i; do cat $i; done|cat - ~/.vimrc|sed '/^\s*$/d'|sed '/^\s*"/d'|wc -l

解释一下:

grep -l "Author.*`whoami`" 选取包含匹配正则表达式Author.*`whoami`的文件,其中whoami命令当然就是取得当前用户名啦。如果你的Vim脚本里标明的作者和你的系统的用户名不同,请自行修改之。 ~/.vim/**/*[^~] Vim配置目录下的所有文件,但以~结尾的备份文件除外。 (.^@) 前面的条件还不够哦。文件要是非软链接^@的普通文件.。也不知道只用一个.可不可以。 |while read i 将前面管道中的那些文件名,一行行地读到变量i里面来。 cat $i 把文件$i的内容显示出来。 done|cat - ~/.vimrc 把前面的内容-和vimrc文件连接到一起输出。 sed '/^\s*$/d' 空行不算数。 sed '/^\s*"/d' 以引号开头的行是注释,也不算数。 wc -l 数数总共多少行。

我的结果:

看到这个结果,我自己都大吃一惊。没想到一年多以来,自己写了这么多行配置了啊。

不过可能不准确哦。反正我这里竟然算不算软链接都是这么多。哪位有更好的命令不妨留言呀。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK