Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to google from the context menu of the Visual Studio 2015 code editor

how can I modify Visual Studio 2015 to be able to search the internet (my fav search engine happens to be google) from the context menu in the code editor?

Ideally, I would like it to open as a new tab in my (default) external browser, because the internal web browser is still...lacking, shall we say?

I found one extension "web search" for older VS, but I have found no extension that works with VS 2015. I found no article that still works.

For comparison, when you're in Chrome, you can select some text, right click and say Search Google for 'what you selected'.

I think this would be handy when learning new technologies from a project that uses those technologies, or just for help.

like image 645
toddmo Avatar asked Mar 16 '23 03:03

toddmo


1 Answers

Ok this turned out to be fairly easy. I just added a tool to Tools, External Tools

enter image description here

Command: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

Arguments: https://www.google.com/?gws_rd=ssl#newwindow=1&safe=active&q=%22$(CurText)%22

I enclosed the $(CurText) variable around quotes (%22) so that it would search on the exact phrase.

Then, to make it more accessible and actually put it in the context menu (and other places), I clicked the Move Up button to make it the first command, then customized the Standard toolbar to include Tools.External Command 1. I also added it to Other Context Menus | Html Context and Editor Context Menus | Code Window

Then I also went into Tools, Options, Keyboard and associated Tools.ExternalCommand1 with Alt+G

IMPORTANT: Because Visual Studio (still, in 2015) doesn't save some modifications to the IDE until it shuts down, you need to shut down all other instances of VS and then lastly shut down the instance that you used to enact these IDE modifications for them to "stick". And, if VS 2015 is like previous versions, be prepared for the menu / toolbar modifications to simply go away one day, at which point you'll just have to redo them.

like image 200
toddmo Avatar answered Apr 25 '23 23:04

toddmo