Open New File Types and Add Syntax Highlighting in Dreamweaver CS5 on Windows 7

I started exploring Symfony2 a few days ago.  It uses .twig files to manage the templates.  It’s quite common as a developer to encounter new file types.  I want to open these files and have syntax highlighting in Dreamweaver.  I know a few people already talked about this (here and here) but I was still having trouble after following their instructions.  So I did more digging and managed to make twig files open as html files by default.

(1) First, add the file type:

Go to Dreamweaver’s toolbar, edit > preferences, under File Types / Editors, add .twig to the line “Open in Code View:”, mine reads like this:

.js .asa .css .cs .config .inc .txt .as .asc .asr .vb .htaccess .htpasswd .ctp .yml .twig

(2) Second, go to C:\Program Files (x86)\Adobe\Adobe Dreamweaver CS5\configuration\DocumentTypes and find MMDocumentTypes.xml

If you are using Windows 7, the file might be read-only and won’t allow you to save.  To overcome this, find the icon for any code editor in your Windows start menu, Right-click on it and click on “Run as Administrator”.  Using this editor, locate the file.

Since twig is mostly HTML, it should be added to the html documenttype, which should be at the top of the file.  Place it inside both winfileextension and macfileextension so the line reads like this:

<documenttype id=”HTML” internaltype=”HTML” winfileextension=”html,htm,shtml,shtm,stm,tpl,lasso,xhtml,twig” macfileextension=”html,htm,shtml,shtm,tpl,lasso,xhtml,ssi,twig” file=”Default.html” writebyteordermark=”false” mimetype=”text/html”>

(3) Third, go to C:\Program Files (x86)\Adobe\Adobe Dreamweaver CS5\configuration and find Extensions.txt

Add TWIG to the first line and second line, which should be ALL Documents and HTML Documents, respectively.

(4) Fourth, this step is almost identical to the second step, but the file location is different:

C:\Users\Peter\AppData\Roaming\Adobe\Dreamweaver CS5\en_US\Configuration\DocumentTypes

Just do exactly the same thing as in step 2.

(5) Fifth, and yes, this is almost identical to the third step, just the file location is different:

C:\Users\Peter\AppData\Roaming\Adobe\Dreamweaver CS5\en_US\Configuration

And again do the same thing as in step 3.

(6) Close Dreamweaver and start it up again.  Hopefully the file type is now recognized and fires up with syntax highlighting.

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>