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.
Place in ~/.vim/plugin/g.vim or in case of Pathogen:
cd ~/.vim/bundle git clone https://github.com/szw/vim-g.git
Please, don't forget to star the repository if you like (and use) the plugin. This will let me know how many users it has and then how to proceed with further development :).
To lookup a word (or words) in Google use
:Google hello :Google start up
Additionally, you can select words in the visual mode exactly in the same way. Just select words and type
:Google function :Google ruby
There is also a special command named
Gf to prepend the current file type automatically:
:Googlef :Googlef strpos :Googlef 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.
:Google "foo bar" :Googlef " help substitute :Google 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:
:Google " :Google "foo bar
There are just a few global variables (options) you may set in the .vimrc file.
Sets the command used to open the URL. In case of Ubuntu this would be
let g:vim_g_open_command = "xdg-open"
Sets the Perl command. By default it's
let g:vim_g_perl_command = "perl"
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="
Sets the command mapping for vim-g. By default this is Google, but you may want to prefix it to something shorter such as :G or :Go
let g:vim_g_command = "Go"
Sets the command mapping for vim-g's file search function. By default this is Googlef, but you may want to prefix it to something shorter such as :Gf
let g:vim_g_f_command = "Gf"
Copyright © 2012 Szymon Wrozynski and Contributors. Distributed under the same terms as Vim itself.