Skip to content

Instantly share code, notes, and snippets.

@tamago324
Last active May 25, 2020 15:44
Show Gist options
  • Save tamago324/a535c9740a0e163d53c5ca8be59d61f5 to your computer and use it in GitHub Desktop.
Save tamago324/a535c9740a0e163d53c5ca8be59d61f5 to your computer and use it in GitHub Desktop.
検索のハイライトのときだけ、cursorline を ON にする
scriptencoding utf-8
function! s:cb(timer) abort
if v:hlsearch
" マッチする文字があれば、カーソルをつける
if search(@/, 'cnw') !=# 0
if !&cursorline
set cursorline
return
endif
endif
else
if &cursorline
set nocursorline
endif
endif
endfunction
function! s:auto_cursorline() abort
if exists('s:timer')
call timer_stop(s:timer)
unlet s:timer
endif
let s:timer = timer_start(100, function('s:cb'), {'repeat': -1})
endfunction
call s:auto_cursorline()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment