Use Visual Studio Code keyboard shortcuts in Visual Studio

If you use both Visual Studio Code and Visual Studio and don’t want to have to remember two different keyboard shortcuts for every command you can easily configure Visual Studio shortcuts to be consistent with those in Visual Studio Code. This can be setup from the Tools -> Options -> Environment -> Keyboard settings screen.

Visual Studio Code Keyboard shortcuts in Visual Studio

Opening Visual Studio Error and Warning links in StackOverflow using a Chrome extension

You can redirect Visual Studio Error List links from Bing to Google by using a Chrome extension. The same approach can be used to open up search results directly within StackOverflow.com too.

You can use any redirect extension you like but the one I’ll show below is called Redirector. When you click on the error or warning links in the Error List box (above) Visual Studio opens
https://bingdev.cloudapp.net/BingUrl.svc/Get?selectedText=QUERY. We can redirect this to https://stackoverflow.com/search?q=QUERY by creating a new redirect like below. 

Redirect Visual Studio error links to Stackoverflow

The results will now be shown directly on Stackoverflow.com which is useful for me at least as the vast majority of technical solutions I find online come from SO.

Stackoverflow search

 

Opening Visual Studio Error List links in Google rather than Bing

In the Error List window Visual Studio links to Bing search results for each error or warning. This is handy, however in my opinion Google provides much better results so it would be ideal if we could configure VS to search on Google instead. I’m using Visual Studio 2019 (16.6) and couldn’t find a way to do this.

Visual Studio Errors Window

Redirecting ALL Bing searches to Google using a browser extension

Until we are able to configure this from within Visual Studio and assuming you are happy to redirect all Bing searches to Google you can just install an extension such as

depending on your default browser (VS will open the Bing search link in the default browser). If your using Opera, there’s an extension which allows you to run Chrome extensions so you can use ChromeTana on Opera too.

The extensions above will redirect all Bing searches to Google.com including those you manually trigger from Bing.com. If you only want to redirect the links from within the Error List window in Visual Studio or you want a little more control over the Google search results you can use a URL redirect extension such as Redirector which is available on Chrome. Other browsers likely have equivalent extensions.

Redirect VS error links from Bing to Google equivalent using Redirector Chrome extension

If your using Chrome as your default browser you can use Redirector to redirect one specific URL or URL pattern to another. Redirector is lightweight and simple to use but does support advanced redirect scenarios such as those including regular expressions and wildcards.

In this scenario the redirect setup is quite simple, we want to redirect URLs which match

https://bingdev.cloudapp.net/BingUrl.svc/Get?selectedText=*
where the star wildcard is the text to be searched for

to

https://google.com/search?q=$1
where $1 corresponds to the text to be searched for.

Thankfully VS links to bingdev.cloudapp.net rather than bing.com so other bing searches are not impacted. After installing the Redirector extension, create a new redirect to match below and click Save. After that all Visual Studio Error List links should open in Google (assuming Chrome is open first).

Redirector setup for bing to google redirect

Customising Google search results by setting additional URL parmeters

Above we just redirect to Google.com with the q parameter set, but it’s possible to refine your search settings by adding additional parameters such as shown in the example below.

  • num (number of results to show)
  • newwindow (opens results in new window)
  • as_sitesearch (limit results to a certain site eg. stackoverflow.com)

Google search with additional parameters set

 

Changing the internal browser home page to Google in Visual Studio 2019

Visual Studio’s internal browser (Internet Explorer 11) is useful if you want to stay within VS. It can be opened with Ctrl+Alt+R or from View->Other Windows->Web Browser. Its home page is set to Bing by default but thankfully this is configurable and the relevant setting is in Options -> Environment -> Web Browser

Visual Studio confgure internal browser

Free Visual Studio extensions to improve developer productivity

With every release Visual Studio becomes more feature rich, however it doesn’t do everything so it’s helpful to install a handful of Visual Studio extensions to shrink the gaps. Ten Visual Studio extensions I use daily or almost daily to save time and be more productive are below, all are free. Please send in your recommedations if I’ve missed any really good free ones.

Open in Notepad++
Super handy Visual Studio extension which adds a menu command that lets you open any solution, project, folder and file in Notepad++.

Redgate SQL Search
Have used this for years. It allows you to quickly find objects across multiple DBs and then allows you to select them in Object Explorer.

Redgate SQL Search

Open Command Line
Opens a command line at the root of the project and also allows for easy (right click) execution of .cmd and .bat files. I use this regularly to right click and execute .bat files for doing things like running Entity Framework scaffold commands direct from solution explorer.

Execute .bat files by right clicking on them

Roslynator
Roslynator is the closest free product you’ll get to resharper. It has over 500 analyzers, refactorings and fixes for C#, powered by Roslyn. Some of the available refactors are shown below.

Roslynator refactoring samples

CodeMaid
Both CodeMaid and Roslynator Visual Studio extensions are complementary to each other. Similar to Roslynator it has a number of cleanups it will perform on your code. Examples include deleting redundant regions, empty lines and unused using statements. My favourite feature however is CodeMaid Spade which is like an enhanced version of the class explorer you get within Visual Studio Solution Explorer already.

Spade allows you to sort members of a class alphabetically and by construct type (method, interface, class, property etc), it will also give you an indication of a methods Cyclomatic complexity. It’s great for quickly reorganising code as it supports moving code via drag and drop as shown below.

Live Share
Of all Visual Studio extensions available this one is particularly relevant at the moment as so much remote working is happening due to Covid 19. Microsoft Live Share extension enables developers to collaborate with each other more easily by allowing a single developer to share their IDE in an interactive manner. This means developer(s) that join the sharers session will have their own cursor and can edit any file in the solution independent of what other developers are doing.

Installation of Visual Studio is not required to join a session as a browser can be used, so live share also has a lot of potential for conducting interviews and online based training.

Live share inline realtime editing

Regex Tester
Regular expressions can be a pain to work with at the best of times. Used less often than other extensions mentioned but it allows you to test your regular expressions before using them in code and also generates corresponding C# code.

VSColorOutput
Adds colour highlighting to Visual Studio’s Build and Debug Output Windows. Errors are in Red, Warnings in Yellow, build headers are Green. Very helpful for large projects and so simple it’s suprising its not included in Visual Studio by default.

VsColorOutput - change colours in output and debug window

Align Assignments
Available from Microsoft DevLabs, this is a simple Visual Studio extension that aligns assigments to make them more clear and readable. A before and after example is below. 

Before Aligning Assignments

After aligning Assignments

Solution Error Visualizer
Also available from Microsoft DevLabs. It allows you to quickly see which files have warnings or errors in them from within Solution Explorer as well as change the view to only show these files. This feature is in a number of other IDEs and can be a big help when working on large projects or when doing large refactors.

Solution Error Visualizer Visual Studio Extension