Open URL under cursor in Vim with browser

后端 未结 11 1103
一整个雨季
一整个雨季 2021-01-29 20:05

I\'m using Twitvim for the first time. Seeing all the URLs in there made me wonder, is there any way to open the URL under the cursor in your favorite browser or a specified one

11条回答
  •  感动是毒
    2021-01-29 20:53

    I use this script to search gooogle for keyword under cursor:

    nmap g :call Google()
    fun! Google()
        let keyword = expand("")
        let url = "http://www.google.com/search?q=" . keyword
        let path = "C:/Program Files/Mozilla Firefox/"
        exec 'silent !"' . path . 'firefox.exe" ' . url
    endfun
    

    You should use getline('.') and matchstr() to extract url under cursor. The rest is the same.

提交回复
热议问题