View Web-page source in external editor

It’s nice to know that OS X Hints editor emeritus Rob Griffiths still visits the site, as evidenced by his posting of this nifty hint for Firefox users:

I use Firefox as my primary browser, and I spend a fair bit of time looking at source code. I’ve always just opened the source view in Firefox (Command-U), then copied-and-pasted the text to an editor like Coda or BBEdit if I needed to do something with it. Then I stumbled on a couple of advanced Firefox settings that let me save the copy-and-paste step; Command-U now opens the page’s source directly in Coda.

To do this, you need to enter about:config in Firefox’s URL bar, then accept the warning when prompted. In the Filter box, type source.editor, which will show you three variables. Double-click on view_source.editor.external first and change its value to true.

Next, double-click on view_source.editor.path, which will drop down a small sheet in which you enter the path to your preferred editor. The path must be a full complete Unix-style path, and point to the actual executable (not the app bundle). So for Coda, I used /Applications/added/ For BBEdit, you need to actually point to the command-line version (/usr/local/bin/bbedit); to do that, you must have first installed BBEdit’s own command line tools (BBEdit -> Install Command Line Tools). Other editors should work; just dig into the bundle (from Finder’s contextual menu, Show Package Contents) to find the name of the actual binary. Click OK to dismiss the sheet, and you’re done.

From now on, Command-U should open the page source in your chosen editor. If it fails, the code will just open directly in Firefox. To revert to Command-U’s original behavior, just open about:config again, and set view_source.editor.external back to false.

I'm sure the timing of Rob's post had nothing to do with our new Monthly Best Hints Contest. But this one would certainly be an early candidate for this month's prize.

To comment on this article and other Macworld content, visit our Facebook page or our Twitter feed.
At a Glance
  • Read the full review


    • Huge speed boost from previous version
    • Vastly improved support for HTML5
    • Useful new App Tabs


    • No H.264 video support in HTML5
    • Still lags Safari and Chrome in non-Javascript functionality
    • A few rendering hiccups
Shop Tech Products at Amazon