Converting Notepad++ into the perfect R script editor. by Andrew Redd 1) Install Notepad++ version 4.1.2 or later http://notepad-plus.sourceforge.net 2) Goto http://www.stat.tamu.edu/~aredd/r.html a) Download userDefineLang_R.xml and R.api 3) Open (or create is it does not exist) %APPDATA%/Notepad++/userDefineLang.xml and userDefineLang_R.xml, which you just downloaded, in notepad++ a) copy the contents of userDefineLang_R.xml to userDefineLang.xml b) if you have other user defined languages you may have to copy so that proper XML syntax is preserved. 4) Copy R.api to %PROGRAMFILES%\Notepad++\plugins\APIs or the appropriate folder on your system. 5) Open notepad++ and under the start menu goto Plugins>Function List>User Rules 1) From the dropdown box choose R 2) Click `Edit rule' 3) Enter the following into the section rules (without quotes) function begin = '[a-zA-Z]+[a-zA-Z0-9_\.]*<\-[ \t]*function[ \t]*' 6) To run files in batch mode a) Click Plugins>NppExec>Execute. And it will bring up a dialog. b) enter on two separate lines: R CMD BATCH $(FILE_NAME) $(NPP_DIRECTORY)\notepad++ $(NAME_PART).Rout c) click save. and save the script with a name like "run in R and Show output" d) now you have a saved script that will run the R script, currently in the editor and has focus and will load the output into Notepad++. A line could also be added to open the Rplots.ps with ghostview or another viewer. 7) Open the computer properties on windows. Click the Advanced tab. Click on evironment variables. Edit the path to include the R executable directory. I've noticed that windows does not like %PROGRAMFILES% which is what R installs by default. Changing this to 'C:\Program Files\...' or wherever R is installed on your machine will allow for R to be recognized as a valid program. 8) Restart notepad++. congratulations you now have a batch file editor that includes 1) syntax highlighting 2) function recognition and tracking 3) Batch Processing