TextWrangler has support for the automatic commenting and uncommenting of blocks of code. However, it appears that this support does not work for codeless language modules, such as those for Stata and R that I have posted about on this site. As a workaround, I have made two scripts (StataComment and StataUncomment) that will insert or remove the characters “//” from each line of selected text. The scripts can easily be edited to use comment characters for other languages (such as “#” for R). New scripts can also be recorded using the recording function in the scripts menu (and the Prefix/Suffix command under the Text menu).
Keyboard shortcuts. These scripts are far more useful if you assign keyboard shortcuts to them. To do so, select Window > Palettes > Scripts, select the appropriate script and click Set Key (I’m using cmd+m and cmd+shift+m).
Update. These scripts have been updated to GenericComment and GenericUncomment. The new scripts support:
- Stata
- R
- LaTeX
and new languages can be added by directly editing the scripts. I experimented with using only one script to handle both commenting and uncommenting, but there may be cases where you want to comment already-commented lines, and vice versa.