LoginSignup
3
4

More than 5 years have passed since last update.

カレントラインをハイライト付きでechoする。

Last updated at Posted at 2014-07-22

synID系の関数の扱いをすぐ忘れるので備忘録。
タイトルそのままですが、カレントラインをハイライト付きでechoするコードです。

a.png

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>
3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4