I am using a function in my vimrc to detect contents similar to those of a modeline and use that to highlight specific words in the file contents.
The function I'm using is from the answer to my previous question on the topic:
function! s:confhighlight()
let l:matches = matchlist(getline('$'), '^# highlight: \(.*\)$')
if len(l:matches)
let s:matchid = matchadd('Todo', l:matches[1])
endif
endfunction
How can I modify this function to highlight multiple words instead of just one expression?
You can see that here, we're trying to match \(.*\)$')
but that would match only all characters till the end of the line.
I want to match words separated by spaces as below:
# highlight: first second
I expect that all matches of first
and second
will be highligted in the current buffer.
Thanks in advance.