Notepad++ is currently my favorite because it is so easy to add literally any computer language or modify how they are displayed. Here's a screenshot of a Stata .do file:
Adding colors, underlining, and so makes the code much easier to stare at. It also help check your code since "replase" won't be highlighted but "replace" will. It also allows the enhancements many text editors offer: tabbed file viewing, saved sessions, and all that jazz.
Great! But what's this stuff for? When you are in Notepad++, editing your latest .do or .ado file and want to try out the code: if you've followed these directions, you can just hit the F8 or F9 button on your keyboard and send the file to Stata.
CreditsThis is posted simply to add to Friedrich Huebler's excellent page explaining how to pass files into Stata. These are just a few notes on how to (only slightly) tweak the code for use with Notepad++. Friedrich Huebler deserves full credit for the code. I simply tweaked the code for this particular application. (after a little time to figure out AutoIt3). The only reason worth posting this page is for a few comments.
There was also a Statalist post from Jeffrey Arnold with some modifications of Huebler's code. The advantage is that the script feeds the commands into Stata via a text file (instead of cutting & pasting it in). This is the approach I use below. It also uses an .ini file to control program names.
The programs posted below are mostly composed of a verbatim combination of these scripts. I give full credit to them for the "heavy lifting." Looking for Help
For a while, I've had the idea to write a plug-in to extend the capability of Stata and Notepad++. What I would like to do is write a plugin for Notepad++ to be able to create "Cells" of data which can be sent to Stata with one keyboard shortcut. This already exists in Matlab's built-in editor. In theory, this wouldn't be Stata-specific; it could be used for Matlab, SAS, and other programs.
See more on the idea here.
I haven't started trying, mainly because I don't have experience writing Notepad++ plug-ins. If you are interested in teaming up on this, contact me by email.
Steps to run with Notepad ++StataExe and StataWin keys.shortcuts.xml file for your installation of Notepad ++
<Command name="Stata: Do Current File" Ctrl="no" Alt="no" Shift="no" Key="120">"C:\{your filepath}\SEND2STATA.KAK.EXE" do "$(FULL_CURRENT_PATH)"</Command>
<Command name="Stata: Include Current File" Ctrl="no" Alt="no" Shift="no" Key="120">"C:\{your filepath}\SEND2STATA.KAK.EXE" include "$(FULL_CURRENT_PATH)"</Command>
<Command name="Stata: Run Current File" Ctrl="no" Alt="no" Shift="no" Key="120">"C:\{your filepath}\SEND2STATA.KAK.EXE" run "$(FULL_CURRENT_PATH)"</Command>
<Command name="Stata: Run Selected Text" Ctrl="no" Alt="no" Shift="no" Key="119">"C:\{your filepath}\RUNDOLINES.KAK.EXE"</Command>
<Command name="Stata: Help for selected text" Ctrl="yes" Alt="no" Shift="no" Key="119">"C:\{your filepath}\HELPDOLINES.KAK.EXE"</Command>
{your filepath} above with the actual filepath to your new .exe files.
The quotation marks to surround the filepaths as ". These will be replaced (by Notepad++) with actual quotes.C:\Documents and Settings\{Windows User Name}\Application Data\Notepad++\ in Windows XP
or C:\Users\{Windows User Name}\AppData\Roaming\Notepad++ in Windows Vista. You should be able to find it by typing the following address into Windows Explorer: %APPDATA%\Notepad++shortcuts.xml, you will need to restart Notepad++ $(FULL_CURRENT_PATH) is explained on this Notepad++ FAQ page include command)net search getcmds since it's not part
of the Stata package. Then, run the command. Next simply cut and paste everything from
the output file into one of the boxes on the "Keywords List" tab.
userDefineLang.xml file for Stata below.
profile.do file:
window menu append item "stUser" "Notepad++" "winexec C:\PROGRA~1\NOTEPA~1\NOTEPA~1.exe"
global F9 winexec C:\PROGRA~1\NOTEPA~1\NOTEPA~1.exe;
- helpdolines.kak.au3
- rundolines.kak.au3
- send2stata.kak.au3
- send2stata.ini
- userdefineLang_stata.xml
- userdefineLang_current.xml (the file I am using 11-25-08, with SAS, Stata, and Stat-transfer)
- Stata.xml Place in C:\Program Files\Notepad++\plugins\APIs for auto-completion (1-12-09)
Similar to writing and running Stata do files from Notepad++ (above), I have begun to do the same for Stat-Transfer Files.
userdefinelang.xml file here: userdefinelang_stat_txfr.xml
<Command name="Stat-Transfer command file" Ctrl="no"
Alt="yes" Shift="no" Key="120">"C:\Program Files\StatTransfer9\st.exe"
"$(FULL_CURRENT_PATH)"</Command>
LaTeX formatting is built-in to Notepad++. If you've installed Miktex 2.7 and Adobe Reader on windows, here's the Run command:
<Command name="PDFLaTex" Ctrl="yes" Alt="no" Shift="no" Key="190">cmd /c cd /d "$(CURRENT_DIRECTORY)" && pdflatex.exe -shell-escape "$(FILE_NAME)" && DEL "$(NAME_PART).log" && DEL file "$(NAME_PART).aux"</Command>
<Command name="PDFLaTex" Ctrl="yes" Alt="no" Shift="yes" Key="190">"C:\Program Files\Adobe\Reader 8.0\Reader\acrord32.exe" "$(CURRENT_DIRECTORY)\$(NAME_PART).pdf"</Command>
I recently received an email from Jelmer Ypma, who has posted an AutoIt script that can be used to run the file currently open in Notepad++ in a program of choice (based on the file extension). You can quickly see how the .ini file works; it appears you could extend the idea to nearly any file extension.