Custom syntax highlighting in Visual Studio 2010 in a html file - visual-studio-2010

Is it possible to create syntax highlighting for custom defined words in known file type?
For example I want to have VS text editor color the tags <# and #> a specified color when viewed in a html file.
Can you do this, and if so then how is it possible?

Yes, well, certainly this is possible for C++ files and files that Visual Studio recognises; so if VS is set up to recognise your HTML as C++ files you should be good.
You will need to create a usertype.dat file and place it in your
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE
folder (or equivalent for VS2010, this is for VS2008)
This file should have the keywords you want listed separately on each line;
for example; I develop with Qt and I have a usertype.dat file as:
signal
slots
Q_OBJECT
(and so on)
Restart VS and your keywords will be highlighted.
I got the info from here and verified it on my system.

Related

How to write Visual Studio Converter

I would like to write a Converter (usable over File -> Open -> Convert...) so that I can convert build information in non-VS format into a VS-Solution.
Now I could not yet find where in the Extension I can actually create a Converter.
Is there any documentation about all the ways how to extend the VS-UI with the Visual Studio SDK?
It's not documented IMHO (at least I can't find it anywhere). It's based on the content of a file called convert.dir located in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE (for Visual Studio 2010). This file may not exist or its size may be 0.
When defined, it contains a list of lines, each line corresponding to a converter. The line format is 5 values separated by the '|' character, like this;
relative path to .vsz|relative icon path|localized name|localized description|priority
The .vsz file is a standard Visual Studio wizard file.
How to provide a converter that shows up in Convert dialog
In addition, here is a sample about VSProjectConverter for your reference.
https://github.com/ssvaidya/VSProjectConverter

How does Visual Studio choose which editor to use for a file?

My project stores html code fragments for use in templating in files with a custom extension (*.phtml). I find that Visual Studio is inconsistent in its use of editors when I edit these files. Sometimes it provides no intellisense, sometimes it treats the files as XML (which is better than nothing), and sometimes I get lucky and it provides me with the HTML editor.
I've configured Visual Studio to treat *.phtml files as HTML, but that doesn't seem to make any difference.
What more can I do to convince Visual Studio to always use the HTML Editor for *.phtml files?
Right-clicking a file in solution explorer shows an "Open with ..." option, the window that it opens has a choice of editors plus a "Set as default" option.

Visual Studio: Defining File Type Regardless of File Extension

Where to define, what kind of type a particular file within Visual Studio solution is?
I have observed that file extensions do not necessarily have to relate to the actual file types within VS.(observed within Visual Studio 2010, 2012).
For example: I have an existing Visual Studio solution. In another tool, I have created an HTML file with .html extension. After importing it into Visual Studio solution, the file does not gain HTML Intellisense and Code Completion.
On the other hand, I can create an HTML file within Visual Studio through: Visual Studio -> FILE -> New File -> HTML Page
This file will gain all its HTML related Code Highlight, Intellisense, and Code Completion features. I can then rename its extension to, say, .txt. The file will still keep its HTML properties such as code highlight, intellisense, etc..
My question therefore is, where can I define/change, what kind of file type (HTML, CSS, JavaScript) the particular file is, regardless of its extension? This is important, to be able to assign appropriate Intellisense, Code Highlight, Code Completion features.

How do I reformat MSBUILD xml in Resharper or VS Studio?

Both ReSharper 6 and VS 2010 treat my MSBUILD files as XML when it has the .Proj extension, but it will not allow me to reformat the text. The options are greyed out in ReSharper and VS 2010. How do I turn it on? Right now, I am forced to either copy and paste the code into a file with an xml extension reformat and copy and paste it back, or rename the file with an xml extension.
You can write a Visual Studio macro that will do all the renaming and reformatting for you. Macros can be bound to the toolbar and to commands (keyboard shortcuts), so you can make this into a single click/shortcut.
JetBrains answer as of today (2013-12-02) is that project files are excluded from code cleanup. There's a discussion of the issue on their code cleanup page which contains a link to a bug named Verify that Code Cleanup works with MSBuild .proj files which contains the information that the fix version is only 9.0!
So there seems no way short of an external tool to get this done.

Automatically adding specified text at beginning of files in VS 2008

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

Resources