Regex Vim:如何在文件中只保留选定的文本?
我尝试使用以下命令,但不知何故使用了捷径导致错误:Regex Vim:如何在文件中只保留选定的文本?,regex,vim,Regex,Vim,我尝试使用以下命令,但不知何故使用了捷径导致错误:E117:Unknown function:g:ClearAllButMatches。我甚至试着输入:callg:ClearAllButMatches(),但仍然没有用,同样的错误。有什么想法可以让它工作或者其他解决方案吗 function! ClearAllButMatches() let old = @c let @c="" %s//\=setreg('C', submatch(0), 'l')/g %d _ put c
E117:Unknown function:g:ClearAllButMatches
。我甚至试着输入:callg:ClearAllButMatches()
,但仍然没有用,同样的错误。有什么想法可以让它工作或者其他解决方案吗
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>
函数!ClearAllButMatches()
让old=@c
让@c=“”
%s/\=setreg('C',子匹配(0),'l')/g
%d_
放c
0d_
让@c=old
端功能
vnoremap c:callg:ClearAllButMatches()
只需移除g:
:
vnoremap <leader>c :<c-u>call ClearAllButMatches()<cr>
vnoremap c:调用ClearAllButMatches()
谢谢!完全新手的问题:D