A Vim plugin that extracts and opens all URLs found in a given line range.
Plugin 'soheilghafurian/vim-openlinks'Plug 'soheilghafurian/vim-openlinks'Clone this repository into your Vim packages directory:
mkdir -p ~/.vim/pack/plugins/start
cd ~/.vim/pack/plugins/start
git clone https://github.com/yourusername/vim-openlinks.gitThe :OpenLinks command accepts any standard ex range:
:OpenLinks " current line
:5,10OpenLinks " lines 5-10
:'<,'>OpenLinks " visual selection
:%OpenLinks " entire bufferThe plugin maps <leader>x as an operator, following standard Vim conventions:
| Keys | Scope |
|---|---|
<leader>xx |
current line |
<leader>xip |
inner paragraph |
<leader>x5j |
current + next 5 lines |
<leader>xG |
current line to end of file |
V select then <leader>x |
visual selection |
To use a different key, remap the <Plug> mappings in your .vimrc:
nmap <leader>o <Plug>(openlinks)
nmap <leader>oo <Plug>(openlinks-line)
xmap <leader>o <Plug>(openlinks-visual)The plugin detects:
- Scheme URLs —
https://,http://,ftp://,file://followed by non-whitespace characters - Bare domains — words containing a dot followed by a known TLD (
com,org,net,io,dev,edu,gov,co,uk,me,info,app,xyz)
Bare domains are automatically prefixed with https:// when opened. Trailing punctuation (periods, commas, parentheses, quotes, etc.) is stripped from matched URLs.
Shell command used to open URLs. If not set, the plugin auto-detects based on OS:
| OS | Default command |
|---|---|
| macOS | open |
| Linux | xdg-open |
| Windows | start |
let g:openlinks_command = 'firefox'Number of URLs that triggers a confirmation prompt before opening. Default: 40.
let g:openlinks_confirm_threshold = 10Tests use vader.vim. The test runner clones it automatically on first run:
./test/run_tests.shMIT