Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I negate a glob in vim?

Tags:

vim

glob

I am trying to populate the vim arglist with all filenames in a directory that do not include "matcher". I can populate it with filenames that DO include "matcher" using

args *matcher*

Is there a simple way to negate the glob to get all the files that don't match?

like image 761
Sean Mackesey Avatar asked Jul 18 '12 18:07

Sean Mackesey


2 Answers

The only way I know is as follows:

:args * | silent! argdelete *matcher*

The silent! part is needed to omit No match error.

Update. One can also create a handy command to type less keys:

:command! -nargs=* Args args * | silent! argdelete <args>

And use it like this:

:Args *matcher*
like image 132
xaizek Avatar answered Nov 12 '22 20:11

xaizek


xaizek's command is short and clever; unfortunately, it only deals with argument files from the current directory. I've expanded on that to work with any directory, and bundle this with other helpful commands for argument handling in my ArgsAndMore plugin.

like image 27
Ingo Karkat Avatar answered Nov 12 '22 21:11

Ingo Karkat