views:

631

answers:

1

I am using Phil Haack's T4CSS T4 template based on .less

One bad thing about Phil's solution is that visual studio opens the .less files as plain text files rather than as css files. (Thus no intellisense.)

How can I get VS to open a .less file in the CSS Source Editor?

I've tried:

  1. Right Click > Open With, but the CSS Source Editor isn't listed.
  2. Tools > Options > Text Editor > File Extensions, but once again, CSS Source Editor isn't listed.

Can this be done?

+11  A: 

I just posted an extension that does this; you can download it from the Visual Studio Gallery.

The key to the extension is the .pkgdef file:

[$RootKey$\Languages\File Extensions\.less]
@="{A764E898-518D-11d2-9A89-00C04F79EFC3}"

[$RootKey$\Editors\{A764E89A-518D-11d2-9A89-00C04F79EFC3}\Extensions]
"less"=dword:00000028

Note that this extension doesn't do anything to help the CSS language service support Less; nested rules, for example, don't work very well at all (it confuses the CSS language service).

Noah Richards
Is there any way to get the CSS validation engine going on .less files?
Chris F
@Chris Tools->Options->Text editor->CSS->Miscellaneous->untick 'Detect errors' might do the trick.
Arnis L.
Any way of getting a VS2008-compatible version?
Diego
You should be able to set the equivalent reg keys for VS2008; all the extension does is load the .pkgdef file, which is essentially just a .reg file that evaluates properties like $RootKey$.
Noah Richards