Skip to content

Instantly share code, notes, and snippets.

@cszentkiralyi
Last active April 16, 2016 07:15
Show Gist options
  • Star 26 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save cszentkiralyi/dc61ee28ab81d23a67aa to your computer and use it in GitHub Desktop.
Save cszentkiralyi/dc61ee28ab81d23a67aa 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.
" Thanks to @VanLaser for cleaning the code up and expanding capabilities to include e.g. `df`
let g:qs_enable = 0
let g:qs_enable_char_list = [ 'f', 'F', 't', 'T' ]
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
for i in g:qs_enable_char_list
execute 'noremap <expr> <silent>' . i . " Quick_scope_selective('". i . "')"
endfor
@VanLaser
Copy link

I updated your maps with operator-pending mode support (and made it more compact), if you're interested (to pull, or see if there's any problems): https://gist.github.com/VanLaser/a781cd29ccf3526da9ef

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment