Skip to content

Instantly share code, notes, and snippets.

@PeterRincker
Created February 3, 2022 16:13
Show Gist options
  • Save PeterRincker/7aba145d3c93b94ce97862ec2bcbd7ff to your computer and use it in GitHub Desktop.
Save PeterRincker/7aba145d3c93b94ce97862ec2bcbd7ff to your computer and use it in GitHub Desktop.
" keep star from jumping
nnoremap <script> <silent> <expr> * <SID>JustHighlight('*')
function! s:JustHighlight(cmd)
" still messes up ' mark
let s:JustHighlight_view = winsaveview()
augroup just_hightlight
autocmd!
autocmd CursorMoved <buffer>
\ execute "autocmd! just_hightlight" |
\ keepjumps call winrestview(s:JustHighlight_view)
augroup END
call timer_start(1, {-> execute('silent doautocmd CursorMoved')})
return a:cmd
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment