Adding a File Type to Visual Studio

So you are editing a file in your beloved Visual Studio but the type isn’t recognised as source code (e.g a .m file from iPhone Objective C), this is what you need to do to add it to Visual Studio and enable that nice syntax highlighting:

Note: The following is for Visual Studio 2008 but should be very similar for other versions. VS 2008 is version “9.0” in the registry keys paths so just watch out for them, or do a “find” on the keys your after.

  1. Open RegEdit – click the Windows/start button, in the search/run box type “regedit” and press return.
  2. In RegEdit browse to the keys:
    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\Languages\File Extensions
  3. In here you will see all the file extensions that Visual Studio recognises.
  4. Right click the “File Extensions” item and select “New Key” from the menu.
  5. Edit your new keys name and make it “.m”.
  6. Go look at the “.cpp” key in “File Extensions\.cpp”. Double click its “(Default)” string and copy (highlight the text and press CTRL+C to copy) its value (it should be something like {B2F072B0-ABC1-11D0-9D62-00C04FD9DFD9} – you need the whole thing including the brackets.
  7. Go back to your “File Extensions\.m” key. Double click its “{Default}” string entry, paste (CTRL+V) the value into here.
  8. You’re done! Launch Visual Studio and open a “.m” file to check it out.