I want to be able to pass a plain regular expression like so
autocmd BufReadPost * call TextEnableCodeSnip('bash', /^hello/, /^world/, 'SpecialComment')
To a function and use it within as a regular expression without having to convert to a string and back. I want it to have the effect of:
vimfunction! TextEnableCodeSnip(filetype,start,end,textSnipHl) abort " ... execute 'syntax region textSnip'.ft.' \ matchgroup='.a:textSnipHl.' \ keepend \ start=/^hello/ end=/^world/ \ contains=@'.group endfunction
Which modifying the function like so works fine.
I was hoping that changing the line to look like:
\ start=start end=end
and just using the variables directly as the data type they were passed as would suffice. Unfortunately, this fails with the error:
E15: Invalid expression: "/^hello/, /^world/, 'SpecialComment')"
Which leads me to believe vim doesn't support this. Does it in another way? Or do I have to use an intermediary string?
I am new to Vimscript and couldn't find anyone else trying to do the same.