One of the things we spend the most time doing as astronomers is writing text and/or code, whether to develop a pipeline to reduce/plot data, write papers/proposals, or write simulation codes. Choosing a good text editor is just as important as having a good chair to sit on, and can have a big impact on productivity! In this post, I will go over a few of the best text/code editors out there for MacOS X.
Update (Sep 21, 2012 by Kelle): New text editor on the block is Sublime Text and it looks just as powerful as TextMate, but more so. Many packages are available for both LaTeX and Python (but maybe not IDL, as far as I can tell). Check out these tutorials to see some of the more advanced features in action. Sublime will cost your grant (or your advisor’s grant) $70 USD.
If any text editor can be compared to a swiss army knife, it is TextMate. It provides support, through bundles, to over 150 programming languages (C/C++, Fortran, Python, Perl, Ruby, LaTeX, HTML, …) and tools (subversion, diff, mercurial, …). One can create projects with multiple files, search and replace text simultaneously in many files, and typeset LaTeX files. Customizable syntax highlighting makes writing text/code pleasant, and code collapsing and expanding makes editing long programs much more manageable (for example, one can ‘collapse’ if statements and do loops in Fortran). One great feature is the ability to just type ‘mate filename’ or ‘mate directory’ on the command-line, and have the file or directory open in TextMate. A number of bundles are installed by default to support programming languages, but if your favorite one is missing, there are instructions on installing bundles here. Be sure to check out the screencasts to make the most out of TextMate. At around $50, a license is a little pricey, but you can try out a 30-day demo to help you decide whether you like it! There is a 15% education discount, and larger discounts if you order 4 or more licenses.
Emacs needs no introduction, but what I want to mention here is not the old command-line emacs, nor the X11 version xemacs, nor the modified emacs for OSX, Aquamacs, but the official Emacs which is now available in native mode for MacOS X (no X11 needed). Emacs has support for many programming languages, and has fantastic auto-indent capabilities: despite being a heavy TextMate users, I always run Fortran 95 files through Emacs to tidy up the indentation! The Emacs team does not provide pre-built Mac versions, but cutting edge builds can be downloaded from this website. Emacs is, of course, free.
Another (free) powerful text editor that is definitely worth trying out is TextWrangler which is a ‘lite’ version of the commercial editor BBEdit. TextWrangler is simpler than TextMate, but has saved me in a few cases where strange non-ASCII characters have made it into a text file, as it has a nice ‘Zap Gremlins’ feature than can remove any non-ASCII character. Syntax highlighting is of course present, as well as the ability to open multiple files in the same window. One very useful feature is the ability to edit a file directly from an FTP or SFTP server (SFTP basically allows you to access files on any computer that is accessible through SSH).
Finally, no discussion of text/code editors would be complete without mentioning the unavoidable TexShop that many of us already use to write papers/proposals. It is a great LaTeX editor, but many users miss out on some very useful features. Some features that may have eluded users are: if you press the command (apple) key and click on a word in the source, it will show it in the PDF, and vice-versa; there are very useful LaTeX and Matrix windows in the ‘Window’ menu, that make it easy to insert mathematical/greek symbols, and build matrices, without having to lookup how to do this on the web; and there are many scripts to typeset a file, not just the default ‘Latex’: for example, the cryptically named ‘latexmk’ will actually run the usual latex/bibtex/latex/latex that BibTeX users are familiar with.
These are just a few of the text/code editors available on MacOS X, but we think that these are some of the best available. Do you use any of these? Do you know of any other great text/code editors?