Posts tagged ‘text editor’

Executing do-files from text editors

| Gabriel |

Stata now defaults to opening a do-file in the integrated do-file editor rather than just running it. The integrated do-file editor is now pretty good, but I’m a creature of habit and I prefer to use an external text editor (usually TextMate) then pipe to Stata. The current default behavior makes this somewhat inconvenient.

Fortunately, you can change this pretty easily in the preferences. Open Stata’s preferences, go to the “Do-File” tab and then the “advanced” sub-tab. Now uncheck the box that says “Edit do-files opened from the Finder in Do-file Editor.” Even though it says “from the Finder” this also applies to do-files launched pretty much any way you can think of: after-market file managers, text editors, etc.

Alternately, you could rewrite your text editor’s Stata support to use Stata console, but that’s probably overkill.

September 28, 2011 at 5:18 am 3 comments

Misc Links

| Gabriel |

  • Useful detailed overview of Lion. The user interface stuff doesn’t interest me nearly as much as the tight integration of version control and “resume.” Also, worth checking if your apps are compatible. (Stata and Lyx are supposed to work fine. TextMate is supposed to run OK with some minor bugs. No word on R. Fink doesn’t work yet). It sounds good but I’m once again sitting it out for a few months until the compatibility bugs get worked out. Also, as with Snow Leopard many of the features won’t really do anything until developers implement them in their applications.
  • I absolutely loved the NPR Planet Money story on the making of Rihanna’s “Man Down.” (Not so fond of the song itself, which reminds me of Bing Crosby and David Bowie singing “Little Drummer Boy” in matching cardigans). If you have any interest at all in production of culture read the blog post and listen to the long form podcast (the ATC version linked from the blog post is the short version).
  • Good explanation of e, which comes up surprisingly often in sociology (logit regression, diffusion models, etc.). I like this a lot as in my own pedagogy I really try to emphasize the intuitive meaning of mathematical concepts rather than just the plug and chug formulae on the one hand or the proofs on the other.
  • People are using “bimbots” to scrape Facebook. And to think that I have ethical misgivings about forging a user-agent string so wget looks like Firefox.

July 20, 2011 at 3:46 pm

Escaped quotes and syntax highlighting

| Gabriel |

Quotes usually delimit where a string with embedded spaces begin, but sometimes you want the quote to be literal and this requires escaping it. To recycle an example I’ve used before, suppose you wanted to display:

Beavis said "Fire! Fire!"

To get Stata to display this, you would escape the quotes by encompassing them in left and right apostrophes (just like calling a local) so the command would be:

disp `"Beavis said "Fire! Fire!""'

This is a trivial example, but a more realistic application is you might want to put some things that involve quotes inside a local and since the content of the local is itself delimited by quotes you’ll need to escape them.

OK, easy enough, but the problem is that most external text editors don’t appreciate this nuance of Stata syntax and end up showing the rest of the document as quoted text, effectively making the syntax highlighting useless. (Stata’s internal editor doesn’t suffer this problem, but I’m in the habit of using TextMate since prior to Stata 11 the editor didn’t have highlighting and it still doesn’t do code-folding). The solution is to let two syntax-parsing wrongs make a right by putting a single quote in a comment, which Stata will ignore but which the text editor will parse as closing a previous hanging quote. It works like this:

disp `"Beavis said "Fire! Fire!""'
* " this line exists only to let the text editor's parser know that everything is back to normal
disp "see, it works. this quoted text should show up as quoted whereas the word 'disp' appears as a command"

February 7, 2011 at 5:05 am 5 comments

Lyx and UltraEdit

| Gabriel |

I’ve been using the beta of Lyx 2.0 for a few weeks now. The first beta was unstable but the second beta has yet to crash or otherwise give me problems so I’ve gone ahead and committed to the new file format (which is still a dialect of TeX, just a slightly different one). I generally find it to be a big improvement in all sorts of subtle ways, particularly how it resolves subtle dependency issues. For instance, I could never get Lyx 1.6.x to recognize the Aspell dictionary on my Mac so I’d have to run a Ubuntu VM to check my spelling. Lyx 2.0 automatically reads the Mac OS X dictionary.There’s also an amazing “compare documents” feature that lets you diff any two files but instead of standard diff output it gives you something that looks a lot like “track changes” in Word. The full list of features is here.

You can download the beta here. Note that this is an ftp not web link and some browsers don’t do FTP so either use an FTP compatible browser like Chrome, an FTP enabled file manager, or a dedicated FTP client. The “dmg” link is for Macs and the “exe” link is for Windows. Note that the Lyx 2.0.x file format is not backwards compatible with Lyx 1.6.x software although Lyx 2.0 beta can export to the old format.

The other software I’ve been playing with is UltraEdit for Mac, for which I was a beta tester. Overall it strikes me as a very good editor and they’ve made admirable efforts to make it Mac native but it still looks like Windows software because it has one big window with internal demarcation rather than lots of floating pallettes, etc. Anyway I’m going to stick with TextMate (which has better language support for the languages I care about) and TextWrangler (which I find more intuitive for batch cleaning files) but I think people transitioning from Windows to Mac might be well served by UltraEdit, especially if they used it (or similar software like Notepad++) on Windows.

December 21, 2010 at 4:13 am

Editra

| Gabriel |

I hadn’t been paying much attention to Editra since my last comparison shopping of text editors, but recently the project has made some really big strides and is shaping up to be a great cross-platform text editor. Most notably for me, it has both syntax highlighting and code-folding support for Stata. (In addition to R, perl, LaTex, bash, html, and plenty of languages I don’t use).  Furthermore, it now has a plug-in framework for language syntax so adding support for additional languages is easy if you have a Scintilla file. (The old method was to recompile from source — yes, really). There’s also a great “Generate” feature which will let you preserve your syntax highlighting in html, rtf, or tex, though in my experience the tex filter is buggy. (Note that there is a similar “copy as RTF” plug-in for TextMate). Finally, the Mac version comes as a binary and actually looks like a Quartz-native Mac program — no Fink / X11 hassle.

Editra is still considered an alpha release and I remain happy with TextMate for my own use, but if you need cross-platform and/or free, I’d recommend considering it. Note that these features could be especially valuable for teaching stats, since students have little money and use a variety of platforms.

Also, another free cross-platform editor worth checking out is Komodo. It has code-folding and syntax highlighting but as far as I can tell, the Stata syntax only supports highlighting (no folding) and there’s no R support at all, though it has a well-documented plug-in system so it should be feasible for someone to write or port an R syntax file to it.

March 3, 2010 at 4:54 am 2 comments

R and TextMate

| Gabriel |

Now that I’ve started dabbling in R, I figured I needed to get my text editor to highlight the Klingon-esque syntax. TextWrangler and Smultron already support R, but getting it for TextMate requires the Terminal:

cd "~/Library/Application Support/TextMate/Bundles"
svn co http://svn.textmate.org/trunk/Bundles/R.tmbundle/

Note that 64-bit R is buggy so if you have trouble piping scripts from TextMate to Rdaemon (i.e., the command line R running in the background), you can use the bundle editor to redirect it to “R32” instead of just “R” which will force it to use the slightly slower but more reliable 32-bit R. Or if that’s too hard, just stick to piping to R.app instead of Rdaemon.

Also, as long as you’re playing with the TextMate library, you might as well install “GetBundles,” a GUI frontend for browsing the TextMate bundle server.
svn co http://svn.textmate.org/trunk/Review/Bundles/GetBundles.tmbundle/

Note that GetBundles (with “s”) supersedes the now defunct GetBundle (without “s”) that you might see mentioned if you google things like “TextMate Bundle” or “TextMate R syntax”.

December 1, 2009 at 4:54 am 6 comments

TextWrangler 3

| Gabriel |

Version 3.0 of TextWrangler came out yesterday. TextWrangler is an excellent text editor, especially for data cleaning, although I prefer TextMate for writing code.

August 25, 2009 at 1:27 pm

Older Posts


The Culture Geeks