Suppose we have several files f11.txt f21.txt f31.txt f01.txt f02.txt f03.txt

Is there any Vim option such that I can open all files except for f0*.txt?

Something like gvim -O * --exclude=*0*? (-O split files vertically, the first * matches all files, the exclude is supposed to exclude the f0*.txt files)

1 Answer 1


Vim does not provide such an option, but if you are using bash, and have the extglob option set (shopt -s extglob), you can use the !(pattern-list) sub-pattern to match all files except those matching one of the given patterns. (See man bash and search for !(.).

With that, you can open your files using

gvim -O !(*0*)
  • Thanks for your reply, two questions. Do you mean that the line shopt -s extglob should be added into the .bashrc file? If I'm using windows cmd line, is there any way to achieve that? Commented Aug 11, 2015 at 22:44
  • Yes, shopt -s extglob should be added to your ~/.bashrc because it is off by default, at least in bash 4.2.45. I don't know of anything similar in the Windows Command Prompt, but I don't know Windows very well. I use Cygwin to keep my sanity while using Windows.
    – garyjohn
    Commented Aug 12, 2015 at 0:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.