How to create custom CSS intellisense schema in Visual Studio 2005 and 2008
Some time ago I described how to add custom HTML markup intellisense and validation schema to VS 2005 and Visual Web Developer Express. Same steps apply to VS 2008. Here I am going to describe how to add custom CSS intellisense schema.
First of all, you can simply modify existing schema. For example, technically CSS 2.x only defines 16 color names while all modern browsers recognize many more. You can borrow color definitions from IE6 CSS schema and include then in CSS 2.1 schema. See my previous blog post for details. If you want to define completely different CSS schema, here are step by step instructions:
1. Copy existing schema file to use it as a template. CSS schemas are in Program files\Microsoft Visual Studio 9.0\Common7\Packages\1033\schemas\CSS (1033 is for English version, substiture number is you are using localized build). For example, copy CSS21.xml to MyCSS.xml.
2. Open MyCSS.xml and edit it to create desired schema. Note that schema folder contains CSS.XSD file which is XML schema for the CSS schema file.
3. Open RegEdit go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Packages\{A764E895-518D-11d2-9A89-00C04F79EFC3}\Schemas. Typically there are 4 entries there, named Schema 1, Schema 2, etc.
4. Create a new entry that immediately follow the last one. Do not leave any holes in the numbering sequence. For example, if you see Schema 4 as last entry, create Schema 5.
5. Under the new key create File REG_SZ value and specify MyCSS.xml
6. Create Friendly Name REG_SZ value and specify name for the schema. This name will appear in the schema dropdowns in the CSS editor toolbar.
You are done. Restart IDE, open CSS file and your new schema should appear in the dropdown. If schema does not load, most probably is does not validate against css.xsd.
Comments
Anonymous
October 22, 2007
Great post Mikhail. I've been wracking my brain on how I could create an intellisense file for JS. I have a library that I use for development and it would sure be a real benefit if I could define it in intellisense. Any thoughts or pointers? reference docs? I really appreciate the help.Anonymous
October 22, 2007
You can't customize script intellisense in VS 2005, but VS 2008 will pick up your script files automatically and generate all necessary intellisense information. VS 2008 script intellisense engine is 100% brand new. ave a look here: http://blogs.msdn.com/webdevtools/archive/2007/03/02/jscript-intellisense-in-orcas.aspxAnonymous
November 21, 2007
The comment has been removedAnonymous
November 28, 2007
Can this same process (customizing the css intellisense & validation) be done for Expression Web / SPD?Anonymous
November 28, 2007
I believe so. Expression uses similar intellisense engine derived from VS 2005 code base.Anonymous
November 30, 2007
Well, in VS is not trivial to add intellisense to a new file type unless it is some sort of a common format already recognized by VS (such as XML). In LDIF case you would have to implement 'language service' in C# or C++ that provides coloring and statement completion.