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:configin 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.externalfirst and change its value to
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/Coda.app/Contents/MacOS/Coda. 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:configagain, and set
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.
Product mentioned in this article