How to turn on Visual Studio 2010 .css Intellisense on .less file

前端 未结 9 879
遇见更好的自我
遇见更好的自我 2020-12-13 01:30

Does anyone know how to enable css intellisense in a non .css file extension? I have a .less file that is basically a .css file but visual studio will not use .css intellis

相关标签:
9条回答
  • 2020-12-13 02:23

    Another alternative is to name your files '.less.css', then change any references to them in either your master page or your main css file (the one that loads all the other css files with @import statements), then configure the less handler as follows in the 'handlers' section of your Web.Config file:

    <add name="LessCssHandler" type="dotless.Core.LessCssHttpHandler,dotless.Core" path="*.LESS.CSS" verb="*" />
    

    You then get syntax highlighting, less works fine and you've not had to set up new file extensions in vs, load any vs addins, etc, which is handy if you have a team of more than 1 developer.

    If you use a single file to define colours etc, it will have to be named '.less' and imported into each .less.css file with an @import 'exampledefs.less'; statement within that file.

    0 讨论(0)
  • 2020-12-13 02:23

    Late answer, but this is a hackish way to solve it in "pure" VS2010

    #if DEBUG
    <html><head><style>
    #endif
    

    in the top of the file and

    #if DEBUG
    </style></head></html>
    #endif
    

    in the bottom of the file

    0 讨论(0)
  • 2020-12-13 02:27

    Try using the CSS Is Less extension for VS2010:

    http://visualstudiogallery.msdn.microsoft.com/dd5635b0-3c70-484f-abcb-cbdcabaa9923

    Forces .LESS files to open in the CSS editor, without having to change settings or adding HTML tags to your LESS file.

    0 讨论(0)
提交回复
热议问题