A VIM plugin to open urls in the default browser
This plugin aim's is to provide a cross platform API to open a url in your default web browser.
:OpenURL <url>
to open given url in the default web browser:OpenIn <browser> <url>
to open given url in the specified web browser:OpenSearchURL <engine> <search terms>
to search thesearch terms
using registered search engine.The default search engine is
duckduckgo
However,google
,stackoverflow
andwikipedia
are also available. You can change the default by settingg:open_url#engines#default
.Search engines can be added using the API
open_url#engines#add(name, pattern)
where name is a logical name and pattern is a string that represents the search url pattern, use%s
as a placeholder for where the search term is added.:OpenURLFind
to find a url ahead of the cursor on the same line and open it if found. NOTE: This also moves the cursor to the url when found.
These work in both normal mode and visual mode :
- gB: Open url under cursor in the default web browser.
- g<CR>: Search word under cursor using default search engine
- gG: Google search word under cursor in the default web browser
- gW: Wikipedia search word under cursor in the default web browser
The following plug mappings are provided which can be remapped if you prefer different mappings to those provided by default.
<Plug>(open-url-browser)
<Plug>(open-url-search)
<Plug>(open-url-search-so)
<Plug>(open-url-search-google)
<Plug>(open-url-search-wikipedia)
g:open_url_browser_default
changes default browser (Default:xdg-open
)g:open_url_default_mappings
enable/disable default mappings without remapping<Plug>
mappings (Default:1
)
open_url#open(url)
: Open given url in the default web browseropen_url#open_in(app, url)
: Open url in specified application (only supported on mac osx).open_url#engines#add(name, pattern)
: Add a search engine to the list of existing search enginesopen_url#engines#search(engine, term)
: Search for giventerm
using search engine namedengine
open_url#find_url()
: Find and return a url (content beginning with http(s)) on the same line. Returns 0 if nothing found. NOTE: This also moves the cursor to the url when found.
Copyright © Dhruva Sagar. Distributed under the same terms as Vim itself.
See :help license
.