Skip to content

Instantly share code, notes, and snippets.

@rbtnn
Created July 22, 2014 16:06
Show Gist options
  • Save rbtnn/0f3b3dd6d22d1a45b63a to your computer and use it in GitHub Desktop.
Save rbtnn/0f3b3dd6d22d1a45b63a to your computer and use it in GitHub Desktop.
function! s:echo_line_with_hl(lnum, sep)
let line = getline(a:lnum)
let cs = split(line, '\zs')
let xs = []
for c in range(1, len(line))
if diff_hlID(a:lnum, c) isnot 0
let name = synIDattr(synIDtrans(diff_hlID(a:lnum, c)), 'name')
else
let name = synIDattr(synIDtrans(synID(a:lnum, c, 1)), 'name')
endif
let xs += [[cs[c-1], (empty(name) ? 'None' : name)]]
endfor
let b = 1
for x in xs
echohl None
if b
echon 'hi: '
let b = 0
endif
if x[0] is a:sep
echo ''
let b = 1
else
execute 'echohl ' . x[1]
echon x[0]
endif
endfor
echohl None
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment