Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I look at code samples on the web that are linked to as a .c, .cpp, .h etc file, chrome will download it for me as a file.

Is there a way to get it to open the file (which is really just a text file with a different extension, and chrome does open text files in a tab window) in a tab window?

I would rather not have my downloads folder littered with all of these small code files.

I have looked in the chrome preferences, but have not found anything that relates to this.

Running the dev build of chrome, but I would take the option in any current build of the browser.

EDIT: Is there a way to change the way that chrome handles some mime types like text/x-chdr or others?

share|improve this question
    
Can you even edit Google Chrome's file associations? –  iglvzx Mar 11 '12 at 18:25
1  
Not sure what you mean. It generally uses my OSes file associations to open files with the correct extension... –  soandos Mar 11 '12 at 18:29
    
You can manage file associations with Firefox's Options > Applications dialog. If Google Chrome had a comparable feature, you would have the choice to open the files in a new tab or another application directly. As far as I can tell, Google Chrome lacks such preferences. :( –  iglvzx Mar 11 '12 at 18:34
    
Can you write an extension to do this? –  conspiritech Mar 11 '12 at 18:51
    
Are you asking if I personally can, or if chrome supports it? –  soandos Mar 11 '12 at 19:03
show 7 more comments

2 Answers

I used to use Syntaxtic! for Chrome, worked for me. It opens source code in a new tab and then applies syntax highlighting.

share|improve this answer
    
Does not work for me. How do you use it? –  soandos Mar 14 '12 at 2:39
    
I installed Syntaxtic!, but CPP files still open a Save As dialog instead of in a tab as plain-text. –  Synetech Mar 14 '12 at 3:42
add comment

I did a bunch of tests and found that some types always trigger a download from remote location. For example, .bat files always try to download while the similar .cmd type opens as text. Likewise, .cpp files always trigger a download while my own .inc type which is an identical copy of the .cpp with the “cpp” changed to “inc” opens as text.

I haven’t checked the source, but I suspect it’s a built-in behavior. They must figure that if it’s a local file (file:///…), you already have it so it is assumed to be trusted, so open it. If however it is a remote file, don’t open it, instead download it so that any anti-virus software on the system can have a look to be safe.

Surprisingly there do not seem to be any other complaints about this on the Chrome bug tracker. o.O I have submitted a report, so we’ll have to see what they say.

share|improve this answer
    
Thanks. And also surprisingly only 10 users have upvoted (starred) it. +1 (me). –  ChrisJJ Jan 10 at 15:21
    
@ChrisJJ: That number is now up to 17, and I've added a comment with some thoughts about what the user interface should look like. –  Keith Thompson May 22 at 19:37
add comment

Your Answer

 
discard

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.