Vim and matchadd compatibility don't work the same
I am playing around with the match functionality in vim (7.4) and I see some differences between match and matchadd that I cannot figure out.
The pattern I am using is simple to match some text in a specific row and column.
if i try the following it works and highlights the text:
:match Test /\%2l\%>4v\%<7v/
If I try the following it won't:
:call matchadd('Test','/\%2l\%>4v\%<7v/')
'Test' is any selection group.
a simpler template, however, works fine, for example:
:call matchadd('Test','test')
Any explanation or help would be helpful.
+3
kjn
source
to share
1 answer
Remove /
from your regex. You don't need separators when using matchadd()
or any vim function.
call matchadd('Test','\%2l\%>4v\%<7v')
+5
Peter rincker
source
to share