Vimscript 函数不起作用

Vimscript function doesn't work

这是从其他人复制并修改的函数,用于在我的 MacOS Chrome 中以可视模式搜索选定的文本:

function! GoogleSearch()
     let searchterm = getreg("g")
     exec ":!open -a Google\ Chrome \"http://google.com/search?q=" .searchterm . "\" &" 
endfunction
vnoremap <F6> "gy<Esc>:call GoogleSearch()<CR>

但它除了输出命令并说 "Press ENTER or type command to continue" 什么都不做:

我测试了什么

那么这里有什么问题呢?虽然有一些插件提供了这种功能,但我想弄清楚代码有什么问题。

假设 Google Chrome 设置为您的默认浏览器,只要您的 url 有效,您可以简单地删除应用程序调用。

function! GoogleSearch()
     let searchterm = getreg("g")
     exec ":!open \"http://google.com/search?q=" .searchterm . "\" &" 
endfunction
vnoremap <F6> "gy<Esc>:call GoogleSearch()<CR>