Open new Vim window and paste this (a pdoc (php) man page header):
ARRAY(3) 1 ARRAY(3)
array - Create an array
SYNOPSIS
array array ([mixed $...])
DESCRIPTION
Creates an array. Read the section on the array type for more information on what an array is.
PARAMETERS
o $...
- Syntax "index => values", separated by commas, define index and values. index may be of type string
Search for the following pattern, that matches the first non-empty lines in the synopsis header
:set hls /\v^SYNOPSIS\r?\n\zs.*\ze\r?\n\r?\n
Notice how the first line of the synopsis header gets highlighted.
Now use the same regular expression in a :syntax match command:
:set nohls :syntax clear :syntax match pdocSynopsisHeader /\v^SYNOPSIS\r?\n\zs.*\ze\r?\n\r?\n/ :highlight link pdocSynopsisHeader Special
Notice how the syntax does not change, and there is no match for the :syntax match command, despite the same regular expression is used as before.
You can double-check by moving the input cursor to the line in question (line 6) and calling synstack() function:
6G
:echo synstack(line('.'), col('.'))->map( { _, val -> synIDattr(val, "name") })
:syntax list pdocSynopsisHeader
What am I missing ? Some multi-line flag for the regexp ... ?
The regexp should match the same way in when used for a search (with / ) or when used in the :syntax command.
Or otherwise any differences should be documented as such.
9.1 (patches 1-445)
Windows 10 GUI (gvim.exe)
No response
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
This seems more like a usage question and not necessarily a bug (at least not yet).
I see several issues here:
\r?\n is not required, you can always use \n to match a linebreak, independently of what the fileformat option is set.\zs and zero-width matches for syntax matches (not sure if this is documented). The following change works however: syn match Special /\(^SYNOPSIS\n\)\@<=.*$/. I think the difference is where the syntax engine is trying to start the match.:syn-match is not necessarily best-practice for syntax scripts. Better it is to define a region start and end patterns and then explicitly try to match within that region. So try this one instead (which is also more simpler to read:syn region SYNOPSIS start="^SYNOPSIS" end="^$" contains=phpDescription
syn match phpDescription /^\s\+.*$/ contained
hi def link phpDescription Special
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
@chrisbra converted this issue into discussion #14909.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()