简体   繁体   中英

How to do brace expansion tab-completion, for filenames in vim?

In vim (and bash), you can specify alternatives in filenames, eg:

:arga project/html/{index,sitemap}.html

This expands to "project/html/index.html" and "project/html/sitemap.html" (the :arga appends them both to the argument list; you can get to them with :n ).

Now, vim already does some filename completion on this, with TAB , by cycling through the possibilities. For the above example, it would show the index one, then the sitemap one, then back to the original text.

I to be able to type this much:

:arga project/html/{in

and press TAB , and have it complete (even though I'm in the middle of a brace):

:arga project/html/{index.html

and have tab-completion also work for the next one, from project/html/{index.html,sit to project/html/{index.html,sitemap.html .

Is there already an option in vim to do this? If not, how would you implement it?

If this is possible, you'll have to define your own :Arga command and to specify your own expansion function. However as vim has a few things hard-coded in regard of command-line completion, I can't guaranty you that this is possible.

You can have a look at my :SearchIn* commands for examples.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM