Can't open .css file with Visual Studio Commuinity 2017 - css

I'm doing Bob Tabors HTML5 & CSS3 course and in the course he only uses Editor and Internet Explorer. I thought that it would be a bit more convinient if I use Visual Studio to code. The problem, I can't open a .css file directly. I can open it in Visual Studio and it behaves like a normal .css file, but when i try to set the "Always open with" to the devenv.exe it says that the file can't be opened with that programm. .html, .cs and .js all work when I try to open them with the devenv.exe.

Thanks to the advice from #Ivaylo Slavov , I just decided to download Visual Studio Code. Seems to be a faster solution for editing .html and .css files.

Related

File Watcher generate .css file but don't refresh browser and don't apply CSS code

All my colleagues work on Visual Studio (me too before one week), but I switched to Rider. After setup my project I setup file watcher to compile SCSS to CSS.
But I have weird issue when I change something in my SCSS file everything compiles to CSS file, but my page stays the same and doesn't get newly created code from CSS. In Visual Studio we use web compiler and it works great: after any change browser refreshes and get new code.
What do I need to do to use file watcher like web compiler? I really like Rider and didn't want to go back to Visual Studio.

How to set the language a plain text is read as in Visual Studio

I've been using Notepad++ for editing CSS, and for just plain text. In Notepad++ I can paste a block of text and specify if I want the file to be highlighted as HTML, CSS, etc.
How do I set the language that Visual Studio will use to interpret a block of text I pasted from my clipboard? What about when I open a plain TXT file?
Am I using the wrong tool for the job? I've been hearing about "Visual Studio Code". Is that what I should use instead?
In general, Visual Studio works with "Project". It is designed to work with the relevant files for the project, and it will recognize them according to the extension.
In Visual Studio, you can override the default config for the file extension with this docs.microsoft. This configuration will work against all files with this extension, but not against a specific file.
I guess there are plugins that can help on the subject, but as you said, Visual Studio Code is more like a file editor like Notepad++, with very powerful plugins and capabilities. So yes, in case you want an enhanced Notepad++, you need to use the Visual Studio Code and not the Visual Studio.
After using both Visual Studio and Visual Studio Code I can confidently tell you VS Code is so much swifter to open and use while also being very easy to navigate.
VS Code automatically detects the language of your code but you can also switch languages by clicking on the existing language at the bottom.
I highly recommend you use it: https://code.visualstudio.com/

Browser Link Save Changes to SASS files from browser

Is it possible to save css changes that I do in Chrome to the correct places in my sass file in Visual Studio 2015?
I cannot find any information on this.
Thanks in advance.

Why does visual studio think js file is a cs file?

I have a ASP.NET solution in Visual Studio 2008 and I added a file identical to http://plugins.jquery.com/files/jquery.cookie.js.txt named jquery.cookie.js in a subfolder of my project containing other javascript files and Visual Studio is treating it as a C# file, giving me errors like CS1012: Too many characters in character literal and Semicolon after method or accesssor block is not valid.
Why?
Open the .js file properties in Visual Studio and make sure that Build Action is Content or None, but not Compile.
Ok, figured it out. I accidentally had runat="server" on one of the <script> tags that included the file. I guess that caused it to try to compile

Open a file in Visual Studio's CSS Source Editor

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:
Right Click > Open With, but the CSS Source Editor isn't listed.
Tools > Options > Text Editor > File Extensions, but once again, CSS Source Editor isn't listed.
Can this be done?
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).
Midscape's Web Workbench Visual Studio Extension adds support for .less files, including syntax highlighting and Intellisense. It also adds support for SASS and CoffeeScript.
If you are using the dotless.Compiler.exe tool (as opposed to the http handler), there is nothing to say your files have to end with .less. I name my suffix my .less files with .css so that Visual Studio treats them like css files. E.g. my naming convention is:
/css/common.less.css ==> /css/common.css
I run the dotLess compiler as a post-build event, e.g.
$(SolutionDir)\packages\dotless.1.1.0\Tools\dotless.Compiler.exe "$(ProjectDir)\css\common.less.css" "$(ProjectDir)\css\common.css"
How to turn on Visual Studio 2010 .css Intellisense on .less file

Resources