synID
系の関数の扱いをすぐ忘れるので備忘録。
タイトルそのままですが、カレントラインをハイライト付きでechoするコードです。
function! s:echo_currline_with_hl()
let line = getline('.')
for c in range(1, len(line))
let name = synIDattr(synIDtrans(synID(line('.'), c, 1)), 'name')
execute 'echohl ' . (empty(name) ? 'None' : name)
echon line[c-1]
endfor
echohl None
endfunction
nnoremap <tab> :call <sid>echo_currline_with_hl()<cr>