Open URL under cursor in Vim with browser

后端 未结 11 857
一整个雨季
一整个雨季 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:40

    I'm pretty late to this party, but here's another way of doing this that works especially well on Windows 7.

    1. Install both vim-shell and vim-misc in vim I recommend doing this via ever-awesome Pathogen plugin and then simply cd ~/vimfiles/bundle & git clone git@github.com:xolox/vim-misc.git & git clone git@github.com:xolox/vim-shell.git from msysgit. (These two plugins open urls in your default browser without creating any extra command prompts or other silly nonsense usually required in windows. You can open urls in Vim like this: :Open http://duckduckgo.com. Try it. You'll like it.)

    2. Create some vim mappings so that you can quickly get the line under the cursor into the browser. I'd map this to u (for me, that's ,u from normal mode). Here's how:

      nnoremap u :exec "Open ".getline(".")

    To use this mapping, type your Leader key from normal mode + u. It should read the line under your cursor and open it in your default browser.

提交回复
热议问题