gpt4 book ai didi

vim - 在vi中打开所有文件(包括隐藏的)

转载 作者:行者123 更新时间:2023-12-03 18:23:31 25 4
gpt4 key购买 nike

我有一个像这样的文件结构

/foo/bar/
├── .foo.cfg
├── foo.cfg
├── foo.data
├── foo.py
├── .svn
│   ├── ...
│   ├── ...
│   └── ...
├── .
└── ..

我想将所有隐藏和非隐藏文件打开到 vim 中。我可以像这样手动完成
vi .foo.cfg foo.cfg foo.data foo.py

但是当有 100 多个文件时这不起作用。我也尝试了以下但没有成功
#hidden files not loaded
vi *

#Includes folders and '.' and '..'
vi * .*

#loads files one at a time
for i in `ls -a` ; do vi $i; done;

#loads files one at a time
find . -name "*" -type f -maxdepth 1 -exec vi {} ";"

最佳答案

以下应该工作:

find . -maxdepth 1 -type f -exec vi {} +

来自 find手册页:

   -exec command {} +  

This variant of the -exec option runs the specified command on the selected files, but the command line is built by appending each selected file name at the end; the total number of invocations of the command will be much less than the number of matched files. The command line is built in much the same way that xargs builds its command lines. Only one instance of ’{}’ is allowed within the command. The command is executed in the starting directory.

关于vim - 在vi中打开所有文件(包括隐藏的),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8405431/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com