Creating a syntax file need to grab a global variable to match.

12 views
Skip to first unread message

Robert

unread,
Aug 19, 2017, 4:50:29 PM8/19/17
to vim_use
One of the plugins that I use allows the end user to redefine a variable to use different markers for text replacement.

It defaults to:

startDelim is: {{+
endDelim is: +}}

I would like to grab the global variable g:startDelim and g:endDelim and use that in my syntax matching group.

Since the end user can remap it and I do using || instead of the curly brackets, I need to grab and use that global variable.

I can force match it to my own choice with:

syntax match mystartKeyword "\v\|\|\+"
syntax match myKeyword "\v\+\|\|"

But that's not optimal.

Is that possible?

Thanks for any help and suggestions.

--
Bob

Sergey Golitsynskiy

unread,
Aug 20, 2017, 1:44:40 PM8/20/17
to vim_use

On Saturday, August 19, 2017 at 3:50:29 PM UTC-5, Robert wrote:
> One of the plugins that I use allows the end user to redefine a variable to use different markers for text replacement.
>
> It defaults to:
>
> startDelim is: {{+
> endDelim is: +}}
>
> I would like to grab the global variable g:startDelim and g:endDelim and use that in my syntax matching group.

Bob -
Have you tried something like this:

exe "syntax match mystartKeyword /" . g:startDelim . "/"
exe "syntax match myKeyword /" . g:endDelim . "/"

I've tried it - works fine.

Sergey

Robert

unread,
Aug 20, 2017, 3:01:09 PM8/20/17
to vim_use

Worked perfectly! Thanks!

Bob

Reply all
Reply to author
Forward
0 new messages