Visual Studio extension: How to make editor text behave like a link - visual-studio

I would like to write a Visual Studio extension, that makes a part of the text behave like a link: blue, underlined on hover, open a URL on click. (Like the default editor works for http://... texts.)
I can do classification (coloring) and also custom adornments and commands, so I could probably make this "manually", but I wonder if there is an easier way to do that.
I am interested to do this in normal Visual Studio (2017 or newer), not VS Code.

You can use UrlTag.
On how to use tags see Walkthrough: Highlight text and Visual Studio 2017 Extension development tutorial part 5: Highlight code in Editor.

Related

Code color code and highlighting for unity

I have just starting learning how to make games in Unity, using Visual Studio as the Script Editor, I see other people have their Code colour coded and it also has auto completion.
I've followed some tutorials online but nothing has worked for me.
what do I have to install to get it working?
To add auto-completion you have to add the unity visual studio package. To add this package please type in your windows search field: "Visual Studio Installer" and then click at the visual studio version the button "change". After that, a new window opens in this window click the field with the unity package and then install this package. Now you have auto-completion in Visual Studio.
To add colors look this video: https://www.youtube.com/watch?v=_g1TyAGk6Lk& I really recommend this color theme.
The Color Coding of Code can be found on the Tools>Options>Environment>Fonts and Colors. For example, you want to change the color for the Operators (+, -, /, *, etc.), you would need to find it in the Display items List and edit (found on the Right Side of the Display Items) the color of the foreground (the text itself), it's background or whether it is displayed in bold or not.
I believe that auto completion or IntelliSense is on by default as for what I have Experienced in switching from MonoDevelop to Visual Studio 2017.
Actually, i think you're looking at a popular visual studio plugin called Resharper;
https://www.jetbrains.com/resharper/
It also has a Unity3D plugin (for resharper) which adds full support. That's were the coloring and extra intellisense comes from.
You can see some sample pictures here; https://github.com/JetBrains/resharper-unity

Refactor on save in Visual Studio 2019

I love Prettier for VS Code. I want to do similar things in Visual Studio (2019).
It now has 'Wrap, indent, and align parameters or arguments' for example (https://learn.microsoft.com/en-us/visualstudio/ide/reference/wrap-align-indent-parameters?view=vs-2019); and I'd like to do this automatically whenever I save the file.
Does anyone know if this is possible? Or if there's a free extension that can do this?
Mads Kristensen (a Microsoft employee who makes scads of Visual Studio extensions and teaches you to too!) made a JsPrettier extension for "classic" Visual Studio (ie, not VS Code):
https://github.com/madskristensen/JavaScriptPrettier
It does not format on save if you set that up in its settings.
If it's literally Prettier in Visual Studio that you're after, this isn't a bad option.
I don't know of a free plugin but you can get quite a long way towards this with some muscle memory and the built in autoformat command.
CTRL+E, CTRL+D, CTRL+S
will do code indentation and formatting, and save the file.
If you have Resharper (sorry), there's a configurable code cleanup tool which will do what you want and CTRL+E, CTRL+F, CTRL+S will do the cleanup and save.
The Format document on Save VS extension does exactly what you want, with one exception. It automatically runs Visual Studio's code cleanup command on save.
Visual Studio's code cleanup commands covers many code style preferences and can be configured with a .editorconfig file. Unfortunately one thing that is not supported by VS yet (not counting Resharper) is line wrap preferences. There is an open ticket for this: dotnet/roslyn#33872
If and when Roslyn supports line wrap preferences (presumably as a new .editorconfig preference), then Visual Studio code cleanup will enforce it and the extension will apply it on save.

Visual Studio 2015: Lines in text editor

Is there any option to display vertical lines in VS2015 like in Notepad++ in text editor which indicate/wrap specific block (from { till })?
Like this:
Yes, try installing the extension called "Indent Guides". It does exactly what you want.
There's also the extension "Productivity Power Tools" which provides this, but it comes with more things which you may not want. If you just want the vertical guidelines and nothing more you should go for "Indent Guides".
The Indent Guides extension mentioned by Yan is an excellent one. Should be perfect for your needs. I have linked to it below. It is free and compatible with Visual Studio 2015, 2013, 2012
Indent Guides - Visual Studio Extension
Once it's installed, you can activate it like this:

Visual Studio surround with current line if nothing selected

I'm using the Surround With feature in Visual Studio with some custom code snippets. Is there a way to configure visual studio (or a custom surround snippet) to treat the entire line like it is selected, if there is currently no selection?
The same functionality is provided when you do a keyboard shortcut such as Ctrl+C, Ctrl+V etc. If you have no selected text, it performs the action on the entire line.
If someone still wants to answer this as far as doing this with Visual Studio's native functions, they can - However it was pointed out to me in a comment that resharper does this automatically. Which is something I did not realize. Seem's I'll be moving all my VisualStudio surround snippets over to Resharper Surround templates!

Colored build output in Visual Studio

I am using a Visual Studio project with custom build script/batch file (ala make, ant, etc.).
When the build is run from the command line we have placed colored highlighting on various output lines.
However, when built via Visual Studio (2005 in my case) the output window does not show the color anymore.
Is this possible? I am quite happy to put specific code into the build script if required.
If you don't want to go with the pro version of the VSCommands plug-in, there is a free one called VSColorOutput, which does just that. I've worked with it a bit, does what it says.
See http://coolthingoftheday.blogspot.com/2011/12/vscoloroutput-visual-studio-output.html or look it up in the extension gallery.
The VSCommands plug-in for Visual Studio 2010 adds colour formatting to the output window so errors are red. I'm not sure how they are doing it but it might give you a starting point.
The problem isn't with your build scripts, but with Visual Studio not supporting ANSI control codes to change the color.

Resources