Why does the Windows open CSS file with notepad

file extension

In CMD I get this:

C:\>assoc .css
.css=CSSfile

C:\>ftype CSSfile
File type 'CSSfile' not found or no open command associated with it.

But in explorer, CSS files have icon and I can double click and notepad is used to open it. Why does my Windows open CSS file with notepad?

I'm not asking HOW to open a file with certain program. I'm asking WHY .css file is associated with notepad, given "File type 'CSSfile' not found or no open command associated with it" ftype command tells.

Best Answer

Why does my Windows open CSS file with notepad?

Right click on the CSS file and click "Open With" > "Choose default program..."

You will see the the default program is set to "Notepad":

enter image description here

You can use this dialog to change the default application if you wish to do so.

In the registry the key HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.css has value PerceivedType set to text:

enter image description here

Warning:

  • Do not modify this entry. It is mentioned only to explain why Notepad is the default program.

Notepad is the default application for opening text files.

You can open the css file in a cmd shell by typing it's name and it will also open in notepad:

enter image description here


Why Notepad is the default application for opening text files?

If I have VIM, how do I make VIM the default application for extensions whose PerceivedType is text?

Notepad is registered as the command to be executed for files of perceived type text.

To change the command to vim edit the registry values described below and replace %SystemRoot%\system32\NOTEPAD.EXE with the path to vim.exe.

Registering a Perceived Type

Registry values for perceived types are defined as subkeys of the HKEY_CLASSES_ROOT\SystemFileAssociations registry subkey.

For example, the perceived type text is registered as follows:

HKEY_CLASSES_ROOT
   SystemFileAssociations
      text
         shell
            edit
               command
                  (Default) = "%SystemRoot%\system32\NOTEPAD.EXE" "%1"
            open
               command
                  (Default) = "%SystemRoot%\system32\NOTEPAD.EXE" "%1"

A file type's perceived type is indicated by including a PerceivedType value in the file type's subkey. The PerceivedType value is set to the name of the perceived type registered under HKEY_CLASSES_ROOT\SystemFileAssociations registry subkey, as shown in the previous registry example.

To declare .cpp files as being of perceived type "text", for example, add the following registry entry:

HKEY_CLASSES_ROOT
   .cpp
      PerceivedType = text

Source Application Registration

Related Question