How do I write a custom keybinding feature in Visual Studio? - visual-studio-2013

I set up a Phabricator code review system in my company. We develop C# applications in Visual Studio.
I have a need to navigate between Visual Studio and Phabricator. Say, if I was editing a file E:\FHT360\Enterprise SNS Project\Enterprise360\SiteMapGenerator\Program.cs in Visual Studio, I want one key press that leads me to http://192.168.0.110:8051/diffusion/FHT/browse/Enterprise%20SNS%20Project/Enterprise360/SiteMapGenerator/Program.cs.
I was thinking about macro first but figured out that it wasn't available in VS2013. Is developing a VS Extension my only option?
I also use Sublime Text and I know how to do such a thing in a few lines of Python code but in VS, I can not find an obvious way to do it.
Thanks for any suggestions.
[Update]
I used Visual Commander and the code is as simple as:
using EnvDTE;
using EnvDTE80;
using System;
using System.IO;
using System.Web;
public class C : VisualCommanderExt.ICommand
{
public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
{
string phabricatorBrowseRoot = #"http://192.168.0.110:8051/diffusion/FHT/browse/";
string path = DTE.ActiveDocument.FullName;
var restPath = path.Split(new char[]{'\\'}, 3)[2];
string url = Path.Combine(phabricatorBrowseRoot, HttpUtility.UrlPathEncode(restPath));
//System.Windows.Clipboard.SetText(url);
System.Diagnostics.Process.Start(url);
}
}

To create a custom command in Visual Studio 2013 you can use Visual Commander or Macros for Visual Studio 2013.

Related

visual studio 2022 auto complete not working like it used to work in 2019

hi I installed the new visual studio 2022 and now my auto complete is not working like it used to work in visual studio 2019 even though I imported my old configs.
I am using visual studio togheter with Unity.
When I want to write a new Function like:
public void OnAnim(){
}
when I enter "("
it autocompletes to
public void OnAnimatorIK(int layerIndex) {
}
and I don't want that. But I want to see the sugestions, but I want it only to autocomplete on "enter" oder "tab" and not on "("

Is there a way to extract comments from code files with DTE (Visual Studio Automation)?

I want to extract comments from code files in a Visual Studio extension. Is there a way to do it using Visual Studio Automation without having to parse code text myself?
PS: Roslyn is not a choice, because I'm not restricted to C# and VB.NET only.
Various code elements like CodeClass and CodeFunction have the Comment property that return the header comment, accessible using Visual Studio code model.
And if a document is opened in VS editor, you can check SnapshotSpan classifications for PredefinedClassificationTypeNames.Comment.

Is there a Visual Studio command to change the Output Window's `Show output from` setting?

At the top of the Visual Studio Output Window is this little dropdown thing:
Is there a command to change this setting, or, perhaps, simply reset it to Build? I'd like to be able to go back to the build output via a keyboard shortcut of some kind, but there's nothing obvious in Tools>Options>Keyboard...
I'm using Visual Studio 2017.
You can create the following command (language C#) with my Visual Commander extension and assign a shortcut to it:
public class C : VisualCommanderExt.ICommand
{
public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
{
foreach (EnvDTE.OutputWindowPane pane in DTE.ToolWindows.OutputWindow.OutputWindowPanes)
{
if (pane.Name == "Build")
pane.Activate();
}
}
}

Custom shorthand Visual Studio 2017

Is there a way to create custom shorthand's in Visual Studio 2017.
Just like ctor or prop?
I would like to create a shorthand for unit-tests, to just type in for instance test and then having a predefined function to edit like:
public void Method_Condition_Expected()
{
// Arrange
// Act
// Assert
}
As #Peter B has suggested for Visual Studio itself you can do it with Snippet Designer (Tools->Code Snippets Manager).
I found out right now, that my installed Tool ReSharper (2016.3) has an option to create so-called Live-Template's.
With that, I can create a Template like this:
public void $Method$_$Condition$_$Expected$()
{
// Arrange
// Act
// Assert
}
The nice part is now, that i can tab through Method,Condition and Expected and overwrite the values.
How to use: Mark a Code-Area such like the code Above in Visual Studio then click on Resharper->Tools->Create Live Template from Selection->Create and Edit.
Now wrap code-areas for tabing through with $ for instance like $Method$ and give a shortcut name such like test.
I hope this helps somebody else as well.
For a closer Comparision between Visual Studio Snippet Manager and Resharper Live Templates see Difference between Live Template and Visual Studio Snippet

How to insert code snippet for Debug.WriteLine(); in Visual Studio?

I can simply insert code snippet for the Console.WriteLine(); by just using the cw with Tab + Tab. But I'm not able to find the same option for the Debug.WriteLine();.
I want to know how can we customize the code snippet template in Visual Studio for Windows Phone?
In Visual Studio 2010 (and assuming other versions as well), there is not a snippet for Debug.WriteLine(). In that case, you'll need to create a custom snippet. Fortunately, it isn't that hard with the available resources:
MSDN: Creating and Using IntelliSense Code Snippets
The Snippet Editor
Snippet Designer (Visual Studio Extension) and the related CodePlex Site
If you're using ReSharper, then Code Templates and specifically Live Templates are a quick and easy option.

Resources