Skip to content

dhruvasagar/vim-open-url

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VIM Open Url v0.5.4

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.

API

VIM Command :

  • :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 the search terms using registered search engine.

    The default search engine is duckduckgo However, google, stackoverflow and wikipedia are also available. You can change the default by setting g: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.

VIM Mappings :

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)

VIM Variables :

  • 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)

VIM autoload function :

  • open_url#open(url): Open given url in the default web browser
  • open_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 engines
  • open_url#engines#search(engine, term): Search for given term using search engine named engine
  • 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.

License

Copyright © Dhruva Sagar. Distributed under the same terms as Vim itself. See :help license.

About

A simple plugin for opening urls in browser

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •