In a vimscript-function, I need to assign a matched string to a variable
l:matched after calling
search() and I am wondering if there is a shorter way than what I am currently doing:
let l:pattern = '\v^Foo: \zs.*' let l:line = search(l:pattern) let l:line_text = getline(l:line) let l:matched = matchstr(l:line, l:pattern)
Ideally, I'd want something like
let l:matched = search_text(l:pattern)
without resorting to
getline(). Is there such a vim function that I seem unable to find?