sponsor Vim development Vim logo Vim Book Ad

vim-g : Quick Google lookup directly from Vim

 script karma  Rating 2/2, Downloaded by 1839  Comments, bugs, improvements  Vim wiki

created by
Szymon Wrozynski
 
script type
utility
 
description
vim-g

vim-g is a tiny plugin that allows you to perform a quick Google search directly from Vim. It opens a new browser window with results. vim-g uses Perl for url encoding.

The most recent version can be found on Github: https://github.com/szw/vim-g

Usage

To lookup a word (or words) in Google use G command:

:G hello
:G start up

G command can use a word under the cursor. Just move the cursor to the word and type the same command in the command line:

:G

Additionally, you can select words in the visual mode exactly in the same way. Just select words and type :G. You can also prepend your selection with more clues:

:G function
:G ruby

There is also a special command named Gf to prepend the current file type automatically:

:Gf
:Gf strpos
:Gf function

There is also a special command named Gf to prepend the current file type automatically:

:Gf
:Gf strpos
:Gf function

Moreover, you can use double quotes (") to perform phrase search. Just enclose some words between quotation marks as you type. Also, you don't have to close manually open quotation marks. vim-g will add the missing one itself.

Examples:

:G "foo bar"
:Gf " help substitute
:G foo bar " something else

What's even more interesting this also works in the visual mode. Therefore, you can perform a strict phrase search on selected words. Just select words and type:

:G "
:G "foo bar

Configuration

There are just a few global variables (options) you may set in the .vimrc file.

    g:vim_g_open_command

    Sets the command used to open the URL. In case of Ubuntu this could be "xdg-open" and that is the default value:

    let g:vim_g_open_command = "xdg-open"

    g:vim_g_perl_command

    Sets the Perl command. By default it's "perl":

    let g:vim_g_perl_command = "perl"

    g:vim_g_query_url

    Sets the query URL. By default it points to Google of course, but you might want to place your favorite search engine there:

    let g:vim_g_query_url = "http://google.com/search?q=";

License

Copyright © 2012 Szymon Wrozynski. Distributed under the same terms as Vim itself.

See :help license
 
install details
Installation

Place in ~/.vim/plugin/g.vim or in case of Pathogen:

cd ~/.vim/bundle
git clone https://github.com/szw/vim-g.git
 

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-g.zip 0.0.5 2013-01-01 7.0 Szymon Wrozynski Added Vim help file
szw-vim-g-0.0.4.zip 0.0.4 2012-08-23 7.0 Szymon Wrozynski Automatically close every open quotation mark, not only the standalone ones.
szw-vim-g-0.0.3.zip 0.0.3 2012-08-22 7.0 Szymon Wrozynski Adds support for strict phrase search
szw-vim-g-0.0.2.zip 0.0.2 2012-08-22 7.0 Szymon Wrozynski Initial upload
ip used for rating: 3.91.106.157

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