There are two issues here.
First, 'wildignore'
takes a list of separate patterns, split by comma, so you actually need to escape the comma with a backslash for it to work inside the \\\{n,m\}
pattern inside 'wildignore'
. So what you actually need as a value is ntuser.dat.log[0-9]\\\{1\,\}
.
But, second, the :set
command will use backslash as an escape character, so in order to get one backslash in the actual value of the option, you need to pass it two (the first one to escape the second.) So, in effect, you need to double the backslashes that you pass.
This is the actual command that works:
set wildignore+=ntuser.dat.log[0-9]\\\\\\{1\\,\\}
Note that if you use :set wildignore?
to inspect it later on, you'll see the actual value with the correct number of backslashes, three before the {
and one before the ,
and }
each.
I tested this setup with files named ntuser.dat.log
followed by numbers (of varying lengths) and non-numbers that would not match the pattern. It seemed to work as expected for me.
If you want to reproduce my testing:
- Create a test directory and
cd
into it:
$ mkdir ~/testwildignore
$ cd ~/testwildignore
- Create files named after the wildignore pattern to test:
$ touch ntuser.dat.log ntuser.dat.log0000000 ntuser.dat.log00000001123 ntuser.dat.log0 ntuser.dat.log00000001122348y3249873297498 ntuser.dat.log99
Of these, all are ignored except for two, the one with no numbers and the one with a letter (y
) among the numbers.
- Create a local test
vimrc
with only two lines:
$ cat test_vimrc
set wildmenu
set wildignore+=ntuser.dat.log[0-9]\\\\\\{1\\,\\}
- Start Vim with this vimrc:
$ vim -N --noplugin -u test_vimrc
- Inside Vim, type
:e
, space, then Tab.
The wildmenu you see will only include:
ntuser.dat.log ntuser.dat.log00000001122348y3249873297498 test_vimrc
:e ntuser.dat.log
As you can see, all files except the two that don't match the pattern have been filtered out.
vim --noplugin
--noplugin
, then I don't get an error at first, but I get the error once I start loading buffers. In any case, the wildignore setting doesn't seem to have worked after testing with glob().set
command)? Always good to verify it that way before trying it in your vimrc, if you haven't already.