Skip to content

Instantly share code, notes, and snippets.

@yukpiz
Created August 24, 2015 04:00
Show Gist options
  • Save yukpiz/805c5d795d0334debd55 to your computer and use it in GitHub Desktop.
Save yukpiz/805c5d795d0334debd55 to your computer and use it in GitHub Desktop.

Vimで現在行のURLをブラウザで開く

以下が必要。

nnoremap <C-o> :call OpenBrowserParsedURL()<CR>
inoremap <C-o> <ESC>:call OpenBrowserParsedURL()<CR>

function! OpenBrowserParsedURL()
    let mlist = matchlist(getline('.'), '\vhttps?\:\/\/[^\>|^\|^\"|^'')]*')
    if mlist != []
        call openbrowser#open(mlist[0])
    else
        echo 'URL is not found in the current line.'
    endif
endfunction

URLが含まれる行にカーソルを合わせて<C-o>でブラウザが開く。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment