Skip to content

Instantly share code, notes, and snippets.

@PeterRincker
Created February 3, 2022 16:13
Show Gist options
  • Select an option

  • Save PeterRincker/7aba145d3c93b94ce97862ec2bcbd7ff to your computer and use it in GitHub Desktop.

Select an option

Save PeterRincker/7aba145d3c93b94ce97862ec2bcbd7ff to your computer and use it in GitHub Desktop.

Revisions

  1. PeterRincker created this gist Feb 3, 2022.
    14 changes: 14 additions & 0 deletions sticky-star.vim
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    " 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