Skip to content

Instantly share code, notes, and snippets.

@craigp
Forked from cszentkiralyi/context_quick_scope.vim
Last active August 29, 2015 14:27
Show Gist options
  • Save craigp/15ca9a96df8b6eb19254 to your computer and use it in GitHub Desktop.
Save craigp/15ca9a96df8b6eb19254 to your computer and use it in GitHub Desktop.
Only enable the quick-scope plugin's highlighting when using the f/F/t/T movements
" Insert into your .vimrc after quick-scope is loaded.
" Obviously depends on <https://github.com/unblevable/quick-scope> being installed.
function! Quick_scope_selective(movement)
let needs_disabling = 0
if !g:qs_enable
QuickScopeToggle
redraw
let needs_disabling = 1
endif
let letter = nr2char(getchar())
if needs_disabling
QuickScopeToggle
endif
return a:movement . letter
endfunction
let g:qs_enable = 0
nnoremap <expr> <silent> f Quick_scope_selective('f')
nnoremap <expr> <silent> F Quick_scope_selective('F')
nnoremap <expr> <silent> t Quick_scope_selective('t')
nnoremap <expr> <silent> T Quick_scope_selective('T')
vnoremap <expr> <silent> f Quick_scope_selective('f')
vnoremap <expr> <silent> F Quick_scope_selective('F')
vnoremap <expr> <silent> t Quick_scope_selective('t')
vnoremap <expr> <silent> T Quick_scope_selective('T')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment