Last active
May 25, 2020 15:44
-
-
Save tamago324/a535c9740a0e163d53c5ca8be59d61f5 to your computer and use it in GitHub Desktop.
検索のハイライトのときだけ、cursorline を ON にする
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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