Reputation: 634
I'm trying to get to vim or nvim to highlight the entire gui line if there is a match on the screen.
I have no idea how to begin approaching this or what to search for.
I'm able to get vim to highlght according to a pattern match, but I want it to highlight the entire gui width like it does at the bottom of the screen (in black) as shown above.
How can I achieve this?
Upvotes: 1
Views: 181
Reputation: 439
As far as I know, it is not possible to highlight the entire line except sign
feature. The following example uses @/
register value to find the last searched lines and will show the Search
highlight on them.
function! s:ToggleHighlightSearchLines()
if !exists('s:id')
let s:id = localtime()
let lc = [line('.'), col('.')]
call cursor([1, 1])
let s:sc = &signcolumn
let &signcolumn = 'no'
sign define hlsLines linehl=Search
let s:sp = 0
while 1
let ln = search(@/, 'W')
if ln == 0 | break | endif
execute 'sign place ' . s:id . ' line=' . ln . ' name=hlsLines'
let s:sp += 1
endwhile
call cursor(lc)
else
while 0 < s:sp
execute 'sign unplace ' . s:id
let s:sp -= 1
endwhile
sign undefine hlsLines
let &signcolumn = s:sc
unlet s:id s:sp s:sc
endif
endfunction
command! ToggleHLSLines call s:ToggleHighlightSearchLines()
Upvotes: 1