如何让 vim 在不同选项卡中打开与模式匹配的所有文件? [英] How do I make vim open all files matching a pattern in different tabs?

查看:28
本文介绍了如何让 vim 在不同选项卡中打开与模式匹配的所有文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在给定的工作目录中,如果我这样做

In a given working directory, if I do

:tabe **/test*.py

vim 抱怨 E77: Too many file names.如果我希望它在单独的选项卡中打开每个匹配的文件怎么办?一定有办法,但我找不到.

vim complains with E77: Too many file names. What if I want it to open every matching file in a separate tab? There must be a way to do it, but I can't find it.

推荐答案

你可以像这样使用 args 列表和 argdo :

You could use the args list and argdo like so:

:args **/test*.py
:argdo tabe %

然而,语法事件被 argdo 关闭(以加快正常用例),因此文件将首先在没有语法的情况下加载.您可以使用 :syntax on 跟进它以在所有加载的缓冲区上强制执行语法事件.压缩成一行(需要将 argdo 包裹在 execute 中,以免吸收后面的 |):

However, the syntax event is turned off by argdo (to speed up the normal use case), so the files will be loaded without syntax at first. You could follow it up with a :syntax on to force the syntax event on all loaded buffers. Compressed into one line (need to wrap argdo in execute so it doesn't absorb the following |):

:args **/test*.py | execute 'argdo tabe %' | syntax on

或者,您可以通过以下方式从命令行打开 vim:

Alternately, you can open vim from the command line via:

vim -p **/test*.py

但最多只能有 10 个标签.

But that will max out at 10 tabs.

这篇关于如何让 vim 在不同选项卡中打开与模式匹配的所有文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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