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
This is a sort of improved version of the script originally proposed by @tungd here https://stackoverflow.com/a/9459366/7631731. Keeps vim context and handles correctly URLS containing "#".
function! HandleURL()
let s:uri = matchstr(getline("."), '[a-z]*:\/\/[^ >,;()]*')
let s:uri = shellescape(s:uri, 1)
echom s:uri
if s:uri != ""
silent exec "!open '".s:uri."'"
:redraw!
else
echo "No URI found in line."
endif
endfunction
nnoremap w :call HandleURL()¬