I copied this in to .vimrc
:
function! ClearAllButMatches()
let old = @c
let @c=""
%s//\=setreg('C', submatch(0), 'l')/g
%d _
put c
0d _
let @c = old
endfunction
vnoremap <leader>c :<c-u>call g:ClearAllButMatches()<cr>
It doesn't seem to work. When I use <leader>c
, I am getting this:
E117: Unknown function: g:ClearAllButMatches
Any ideas why its happening?
note:
- I have sourced my .vimrc several times.
Remove
g:
from the mapping or add it to the function name