Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I make C files appear in the browser's window when I navigate to them on a web page? (I use Iceweasel which should be identical to Firefox.)

I don't want to download the file, not open it in Emacs, etc., I just want to view it like any other page.

For example, Perl files (.pl) are OK.

But, C files (.c) have an option line in Preferences -> Applications. Here, I can chose what to do - download them, open in Emacs, etc., but how do I chose to just view them? (Tried to pick Iceweasel - didn't work.)

Ironic thing is, I think "view in browser" is default (as there is no option for Perl files) - so if I could somehow remove the option line for C, that's worth a shot.

share|improve this question

Thank you. I have wanted to do this for ages but never get around to finding a solution. Your question forced me to :).

Solution 1

Use the Open in Browser extension. This works perfectly well but adds some whitespace to the left of each line in the source code file.

Solution 2

Change all extensions to .txt. I often build websites for sharing my data with my collaborators. Since I work on Linux, I often have random extenions that are only informative to me. Things like file1.out or file1.res or file1.thisbetterwork or whatever. I cannot tell them they need to install an extension, so my webpage links to copies of the relevant files with txt extensions that I have made in my server's directory:

$ for i in *.c ; do cp $i /var/www/mysite/sources/$i".txt"; done

This assumes your file names are sane, containing no spaces or other strange characters. Look at my answer here for tips on how to modify it to deal with stranger file names.

This bug offers some background. We are not alone.

share|improve this answer
1 works perfectly (I don't get any whitespace) but, is it possible to make that default? As it is now, I have to pick "Open in browser" every time. As for 2, that works for homepages, but only for homepages - if you were to download the file, ls wouldn't know what color to show it in, Emacs won't set the correct mode, gcc won't compile a (supposed) text file, etc. etc. Although it could be automatized, I'm looking for a better way. – Emanuel Berg Sep 16 '12 at 16:07
Forgot to ask in the above comment: The bug link you posted, that's so much to read, did you read it and didn't find a workaround? – Emanuel Berg Sep 16 '12 at 16:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.