I'm trying to match a new line character on a Vim syntax file, I can make it work when I use the patern within Vim but when I put it in my syntax file it doesn't highlight when I have a new line and when it should.
The regex part that I use for new line match is: \_s
(also tried with \n
with: \(\n\|\s\)
)
The patern: [,(]\(\_s*\w\+:\)\?\_s*\zs\w\+
Simplified version of the patern: [,(]\_s*\zs\w\+
(same for the example and the purpose of the question)
Syntax file code inside .vim/syntax/python.vim
:
syn match pythonFunctionParam '[,(]\_s*\zs\w\+'
[...]
hi link pythonFunctionParam Error
[...]
let b:current_syntax = 'python'
Here is a sample test file to reproduce try: test.py
:
a(matched_by_all=2, matched_by_all="anything")
b( matched_by_all=3,
matched_only_by_vim_search='test'
)
c(
matched_only_by_vim_search=3
matched_by_none="it's normal"
)
When I use Vim integrated search ( /[,(]\_s*\zs\w\+
) I get thoses matches:
matched_by_all matched_by_all
matched_by_all
matched_only_by_vim_search
matched_only_by_vim_search
So everything works has expected
When I use syntax syn match
with the same regex I get different matches (less match):
matched_by_all matched_by_all
matched_by_all
Has you can see when there is a (
or ,
on the same line it will match, but not if it's a new line.
So my question is: How to get the same match in my syntax file ?