In previous versions of Visual Studio I've had knockout.js syntax highlighting.
Since moving to Visual Studio 2017 Community building in Razor however, the syntax highlighting is gone and I found no way to enable it.
Interesting is however, that when I put the very same code into project built on Webforms, the highlighting seems to work at least to some degree
Is there anything I can do to enable syntax hightlighting for Razor? And/Or is there a way how to make custom syntax highlighting rules? [e.g. highlight specific data attribute, or so]
Try this. Also Read the overview.
https://marketplace.visualstudio.com/items?itemName=ms-madsk.RazorLanguageServices
Yes, in our Project we added the file reference on the _references.js file:
/// <reference path="knockout-3.4.0.debug.js" />
This make Visual Studio Intellisense to get the sintax hightlighting on the .cshtml files.
Reference Directives
A reference directive enables Visual Studio to establish a relationship between the script you are currently editing and other scripts. The reference directive lets you include a script file in the scripting context of the current script file. This enables IntelliSense to reference externally defined functions, types, and fields as you code.
Sources:
MSDN - JavaScript IntelliSense
C# Corner - Use of _references.js File
Mads Kristensen - The history behind _references.js
Related
I am using Visual Studio with Unity. When I copy and paste a code in Visual Studio. It automatically adds an unnecessary namespace on the top. It is pretty annoying to see if there have many unused namespaces over time. May I ask if is this a bug or how can I turn off the auto import namespace when copy paste?
From the suggested name, I think Visual Studio confuses the "length" and "Length"
Here are the steps to reproduce the problem
On the top of the page in Visual Studio, go to Tools > Options > Text Editor > C# > Advanced > Uncheck the option for "Add missing using directives on paste" then click OK on the bottom of the page. And then restart Visual Studio.
Might be useful to some to note that tab completion will still auto-add missing using directives.
Here is an example with the option checked (the example specifics are not relevant but in this case an attribute is being pasted to an ASP.Net Core Razor Page):
Here is an example with the option unchecked:
Visual Studio will recognize XML documentation and helpfully display tooltips in the editor based on it. Is there any way (I'm thinking an extension or similar) to get this same functionality from the Doxygen comments?
There is far too much code to move over to XML documentation.
I am looking for some way to edit antlr grammar files directly within VS2010 with syntax highlight.
I have used antlrworks a lot but it has the drawback that I have to start antlrworks separately and then browse to the file I want to edit, do the changed and save. For minor fixes I do not need all the tools in Antlrworks but I still would like the syntax highlight.
But I have not been able to get VS2010 to open antlrworks with the right file and I have found no other way to get syntax highlight directly within VS2010 editor, it just opens as plain text.
I can get visual studio to open antlrworks but it will open with only the last set of files it had open, not the one I clicked on.
So my question(s) are:
Is there a way to get antlrworks to open with the right file when I double click in it in visual studio project explorer?
Is there any other way to get correct syntax highlight for antlr grammar files within visual studio (or with another editor, preferably not one that costs money, but if there are no free ones a commercial one might be an option).
You could try the Tunnel Vision Labs extension. This can be found in Microsoft Gallery
You can provide a custom parser class that Visual Studio uses to highlight ANTLR grammar files.
See: Syntax Colorizing (Managed Package Framework)
I found old article called LearnVSXNow and part #30 - Custom Editors in Visual Studio. There is sample project The Blog Item Editor which shows how to make custom file type assigned with custom UI editor for this file type extension (.blit)
This sample uses project VSXtra, which is written for Visual Studio 2008.
Can someone point me to some tutorial, how-to, or something how to do the same for Visual Studio 2010 ? My goal is to register custom file type extension (e.g. *.myext1) within visual studio 2010, and assign my own custom UI designer (WinForms, derived from UserControl) to handle editing content of such file visually.
I found some samples, but each of that shows only changes on code text editor (highlight some words, etc). But i want to show my own toolwindow with my usercontrol within it.
PS: Part of creating custom toolwindow with my own usercontrol within it is not problem, i use VSPackage Builder Project Template to build and register it within visx. My problem is how to register custom file type to use this custom toolwindow to edit file.
While the core text editor changed significantly (nearly a total re-write, designed around MEF) in Visual Studio 2010, the general infrastructure for registering and supplying custom editors/designers did not change.
The 'Creating Custom Text Editors and Designers' page on MSDN is a good place to start. You should also be able to go through the VSPackage wizard and choose "Custom Editor" to get a basic editor in place. It will give you a simple RTF editor.
You can also check out these samples on the MSDN Code Gallery for more ideas and inspiration:
Editor with Toolbox Support
Designer View Over XML Editor
It is usually recommended that editors reside in a document window (as opposed to a tool window). This is the paradigm that nearly all the built-in editors/designers use in Visual Studio, and it's what users expect when opening something from Solution Explorer. Editing things in a ToolWindow can feel a bit unnatural.
My understanding is that VSXtra provides some additional helper/base classes (beyond what Microsoft supports) to make various tasks (like writing a custom editor/designer) simpler. It is by no means required to create a custom editor though.
Is there a way to have Visual Studio 2008 automatically add heading information to files? For example, "Copyright 2008" or something along those lines. I've been digging through the options, but nothing seems to be jumping out at me.
I assume you'd like to modify the class file templates. They're in:
%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033
More specific details here
I found a better solution than modifying the template file directly. This utility allows you to create and save header/footer templates and apply them to entire source trees.
C# Header Designer from MSDN Code Gallery