-------------------------------------------------------------------------------
----------  Notepad++ with syntax highlighting and code folding for Dynare.  --
-------------------------------------------------------------------------------

Written by Hkon Tretvoll, New York University.
Version 1.0: Based on Dynare commands and options found in the .html version of the Dynare Manual version 4.0.4 + additional commands found in the "New or previously undocumented features"-section of the Dynare Wiki.
Last updated: June 25, 2009. 

-------------------------------------------------------------------------------
----------  Introduction  -----------------------------------------------------
-------------------------------------------------------------------------------

From the Notepad++ website: "Notepad++ is a free source code editor and Notepad replacement that supports several languages." That means it contains syntax highlighting and code folding(*) for the supported languages (which include C, C++, Matlab, Fortran etc.). This text explains how to configure Notepad++ to obtain the same functionality for Dynare, and how to make Notepad++ the default editor associated with your .mod files.

(*) Code folding is a feature of a source code editor that allows you to collapse a certain segment of the code. This helps in making your code more readable as you can 'fold' away code that you're not interested in at the moment. For Dynare I've defined it so that any block of code starting with '<some command>;' and ending with 'end;' or starting with the C-style comment '/*' and ending with the C-style comment '*/' can be folded in Notepad++. Code that can be folded is marked in the left-hand margin of the editor with a minus sign '-'. A vertical line then denotes the segment of code that is collapsed when you click the '-'. The code is hidden and a '+' replaces the '-'. When you click '+' the code reappears. It looks something like this:

'-' shocks;
 |     var eps;
 |     stderr sig_eps;
 |     var eta;
 |     stderr sig_eta;
 |- end;

 And when you click the '-' it collapses to:
 
 '+' shocks;

-------------------------------------------------------------------------------
----------  Instructions  -----------------------------------------------------
-------------------------------------------------------------------------------
 
--Step 1: Download and install Notepad++
You can find Notepad++ as well as a description of its features at the website:
	http://notepad-plus.sourceforge.net/uk/site.htm
In the "Download" section click "Download Notepad++ executable files" and choose the one you prefer. I think it's easiest to download the file ending in .Installer.exe and just running it to install the program. 
 
-------------------------------------------------------------------------------
----------  Steps 2 and 3 for Windows Vista  ----------------------------------
-------------------------------------------------------------------------------

--Step 2: Place userDefineLang.xml in the Notepad++ %AppData% folder
The folder I'm referring to is the location where Notepad++ stores its application data specific to the current user. The path to the folder is:
	C:\Users\<username>\AppData\Roaming\Notepad++

It should be straightforward to find it by right-clicking the Windows logo in the bottom left corner and choosing "Explore". The folder is hidden though, so make sure you have enabled viewing hidden files and folders. To do that, click the following:
	"Tools" -> "Folder options" -> "View" -> "Show hidden files and folders"
(If you can't see the menu with the "Tools" option, press <Alt>.)

Once you've found the right folder, you should see that it contains a bunch of .xml files. Copy userDefineLang.xml into the folder.

--Step 3: Make Notepad++ the default editor for .mod files
Find a .mod file on your system and right-click it. Choose "Open with  >", and choose "Choose Default Program...". In the 'Open with' dialog box, if you see Notepad++ under 'Recommended programs' simply select it and click "Ok". If you don't see it, click the downarrow next to 'Other programs' and find Notepad++ in the list. When you've found it, select it and click "Ok". 

-------------------------------------------------------------------------------
----------  Steps 2 and 3 for Windows XP  -------------------------------------
-------------------------------------------------------------------------------

--Step 2: Place userDefineLang.xml in the Notepad++ Application Data folder
The folder I'm referring to is the location where Notepad++ stores its application data specific to the current user. The path to the folder is:
	C:\Documents and Settings\<username>\Application Data\Notepad++
	
It should be straightforward to find it by right-clicking the Windows logo in the bottom left corner and choosing "Explore". The folder is hidden though, so make sure you have enabled viewing hidden files and folders. To do that, click the following:
	"Tools" -> "Folder options" -> "View" -> "Show hidden files and folders"
	
Once you've found the right folder, you should see that it contains a bunch of .xml files. Copy userDefineLang.xml into the folder.

--Step 3: Make Notepad++ the default editor for .mod files
Find a .mod file on your system and right-click it. Choose "Open with...", and choose "Choose Program...". In the 'Open with' dialog box, if Notepad++ is listed simply select it and click "Ok". If you don't see it, click "Browse...", find the directory where you installed Notepad++ (most likely "c:\Program files\Notepad++\"), select "notepad++.exe", and click "Open". Then select Notepad++ from the list, check the box next to "Always use the selected program to open this kind of file", and click "Ok".

-------------------------------------------------------------------------------
----------  Final notes  ------------------------------------------------------
-------------------------------------------------------------------------------

After completing these steps, all you have to do is double-click a .mod file and it should open in Notepad++ with syntax highlighting and code folding enabled.

Note: If you've already used Notepad++ and defined your own syntax highlighting scheme using the 'User Define Dialog...', the %AppData% (XP: "Application Data") folder will already contain a file named userDefineLang.xml. Obviously you'll lose that syntax highlighting scheme if you overwrite this file. To have both the Dynare scheme and your own defined scheme installed you either have to recreate your scheme after overwriting the file, or merge the two .xml files.
