Vim function doesn't seem to be recognised

2019-08-01 19:47发布

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:

  1. I have sourced my .vimrc several times.

1条回答
ゆ 、 Hurt°
2楼-- · 2019-08-01 20:32

Remove g: from the mapping or add it to the function name

查看更多
登录 后发表回答