如何运行"gg = G"在几个文件上? [英] How to run "gg=G" on several files?

查看:369
本文介绍了如何运行"gg = G"在几个文件上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在vim中,gg=G在重新缩进当前文件方面做得很好,我想对多个文件进行缩进.

In vim, gg=G does a great job re-indenting your current file and I'd like to do that on several files.

我想做这样的事情:

files=`find $1 -type f`
for file in $files
do
    vim -e -s -n "+gg=G|wq" $file
done

问题在于gg=G不是命令(如果在vim中键入:gg=G,则会引发错误),因此它不起作用...

The problem is that gg=G is not a command (if you type :gg=G in vim, it throws an error), so it doesn't work...

推荐答案

我想我找到了! (当然,即使我之前搜索了4个小时,我还是在发布问题后的10分钟之内)

I think I found it! (of course 10 minutes after I posted the question, even though I searched before for 4 hours)

files=`find $1 -type f`
for file in $files
do
    vim -e -s -n "+normal gg=GZZ" $file
done

这篇关于如何运行"gg = G"在几个文件上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆