Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open a file in Visual Studio's CSS Source Editor

Tags:

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?

like image 226
nikmd23 Avatar asked Feb 27 '10 04:02

nikmd23


People also ask

How do I open a VSC file in CSS?

You can quickly navigate to the relevant CSS symbol in the current file by pressing Ctrl+Shift+O.

How do I open an SRC file in Visual Studio?

First, select DevTools > Settings > Experiments > Open source files in Visual Studio Code, and then re-start DevTools.

How do I open a specific file in Visual Studio?

In Visual Studio, click File > Open > Folder. Navigate to the folder, and click Select Folder. This opens the folder in Solution Explorer and displays its contents, files and any subfolders.

How do I add a CSS file to Visual Studio?

In the toolbar of the Manage Styles window, click the Attach Style Sheet button. The Select Style Sheet dialog box is displayed. Select the Layout. css file, and then click OK.


1 Answers

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).

like image 177
Noah Richards Avatar answered Sep 28 '22 15:09

Noah Richards