sponsor Vim development Vim logo Vim Book Ad

vim-www : Toolbox to open & search URLs from vim

 script karma  Rating 1/1, Downloaded by 2491  Comments, bugs, improvements  Vim wiki

created by
Marc Busqué Pérez
 
script type
utility
 
description
Complete information at: https://github.com/waiting-for-dev/vim-www

Usage

vim-www allows launching a web browser from vim to open arbitrary URLs, defined favorites and search engine results.

The web browser to be used is detected automatically, but it can be manually set through g:www_launch_browser_command, using {{URL}}} as placeholder for the actual URL. E.g.:

let g:www_launch_browser_command = "iceweasel {{URL}} &"

In the same way, an alternative CLI browser can be set through g:www_launch_cli_browser_command. In order to work, vim-dispatch add-on must be installed. Its purpose is to open a web, for example, in a tmux pane, or in a virtual terminal if neovim and vim-dispatch-neovim are being used.
Favorites and arbitrary URLs

:Wopen opens any given URL. E.g.:

:Wopen http://vim.org

But typing and remembering full URLs is annoying, so custom favorites can be defined in g:www_urls dictionary.

So, having in vimrc,

let g:www_urls = {
  \ 'vim' : 'http://www.vim.org',
  \ }

following command does the same than previous one:

:Wopen vim

Also, in normal mode, <leader>wo launches the browser using WORD under cursor as URL. In visual mode it does the same but taking current text selection as URL.

:Wcopen command and <leader>wco mappings do the same but using the CLI browser.
Search engines

:Wsearch queries a search engine and opens the corresponding results page:

E.g.:

:Wsearch google how to learn vim

Previous command opens the resulting page of searching how to learn vim in google.

Following search engines are provided by default:

    bitbucket
    devdocs
    duckduckgo
    google
    github
    stackoverflow
    wikipedia

More search engines can be added through g:www_engines dictionary. Query is appended at the end of given URL. E.g.:

let g:www_engines = {
  \ 'youtube' : 'https://www.youtube.com/results?search_query=',
  \ }

In normal mode, <leader>ws searches WORD under cursor, while the same mapping in visual mode searches current visual selection. In both cases, the user is prompted to choose which search engine should be used. If none is given, duckduckgo is used, but this behaviour can be changed setting g:www_default_search_engine variable. E.g.:

let g:www_default_search_engine = 'google'

:Wcsearch command and <leader>wcs mappings do the same but using the CLI browser.
Shortcut search engines

Convenient shortcuts for commonly used search engines can be defined in g:www_shortcut_engines dictionary. Having in vimrc:

let g:www_engines = {
  \ 'ruby' : 'http://ruby-doc.com/search.html?q=',
\}

let g:www_shortcut_engines = {
  \ 'ruby': ['Docruby', '<leader>dr', 'Doccliruby', '<leader>dcr']
\}

automatically adds :Docruby / :Doccliruby commands, and <leader>dr / <leader>dcr mappings that work like :Wsearch / :Wcsearch and <leader>ws / <leader>wcs but using ruby straight away as search engine.

Remember that user defined commands must begin with an uppercase letter.

This is very convenient to use as a quick way to consult API documentation.
Sessions

Arbitrary URLs and favorites can be grouped together under a name in g:www_sessions dictionary and opened at once using :Wsession command.

Having in vimrc:

let g:www_urls = {
  \ 'vim' : 'http://www.vim.org',
  \ }

let g:www_sessions = {
  \ 'dev' : ['vim', 'http://stackoverflow.com'],
  \ }

Running:

:Wsession vim

would open http://www.vim.org and http://stackoverflow.com at once.

:Wcsession command does the same but using the CLI browser.
Configuration and reference

Type :help vim-www for a complete reference and information about configuration.
Bugs

Open a bug in https://github.com/waiting-for-dev/vim-www/issues
Contributing

    Fork the project ( http://github.com/waiting-for-dev/vim-www/fork )
    Create your feature branch (git checkout -b my-new-feature)
    Commit your changes (git commit -am 'Add some feature')
    Push to the branch (git push origin my-new-feature)
    Create new Pull Request

Version

vim-www follows Semantic Versioning System 2.0. Current version is 1.0.0.
License

The MIT Licence http://www.opensource.org/licenses/mit-license.php

Copyright (c) 2014 Marc Busqué Pérez

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
install details
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vim-www-1.1.0.zip 1.1.0 2017-01-17 7.0 Marc Busqué Pérez - Adds cygwin support
- Fixes URL escaping issues
- Revisits and centralizes shell escape and dispatching for all handlers
- Adds gitlab to the defaults
vim-www-1.0.2.zip 1.0.2 2016-06-13 7.0 Marc Busqué Pérez - Fix using custom launch command with URLs with '#'
vim-www-1.0.1.zip 1.0.1 2016-06-07 7.0 Marc Busqué Pérez - Fix bug opening URLs in MacOSX
vim-www-1.0.0.zip 1.0.0 2016-06-02 7.0 Marc Busqué Pérez * Separate ways between favorites (or arbitrary URLs) and search engines. `Wopen` opens the former, and `Wsearch` searches through any given search engine. Configuration variables also change.

* Option to open URLs in a CLI browser using brother commands and mappings if `dispatch.vim` is installed.

* Define shortcut commands and mappings to be able to search a given search engine more quickly.
vim-www.zip 0.0.4 2015-08-27 7.0 Marc Busqué Pérez * Prepend "http://"; to url's without "://"

Bug fixes
* Fix opening search engine url's that are not a www tag
vim-www-master.zip 0.0.3 2014-11-20 7.0 Marc Busqué Pérez Fix behaviour for URLS with "#" character in Linux
vim-www-master.zip 0.0.2 2014-11-20 7.0 Marc Busqué Pérez Renames project to vim-www. It will be then more search engine friendly.
www.vim-master.zip 0.0.1 2014-11-19 7.0 Marc Busqué Pérez Initial upload
ip used for rating: 100.28.2.72

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github