20

All one line

I seem to run into this randomly. It usually displays the file normally, but sometimes it's all scrunched onto one line. I can't figure out what's causing it.

1
  • What did you use to create the file score.js?
    – Joel Lee
    May 1, 2011 at 4:31

3 Answers 3

27

N.B.: In the current version of Chrome, this is actually done by clicking on the {} icon ("pretty print") on the lower left of the developer tools pane.

2
  • 1
    awesome! this was driving me nuts!
    – locrizak
    Nov 28, 2012 at 1:18
  • how can we do this in Internet Explorer ?
    – Vipin
    Nov 27, 2014 at 12:56
5

Ah, figured it out. The line endings on the problem file got set to Mac format somehow, while the rest of the files were Windows format. Not sure how the format swapped but it's easy to convert back (in Notepad++ just go Edit -> EOL Conversion).

1
  • Cheers! I had the same problem, was aggravating the hell out of me!
    – MrE
    Oct 8, 2012 at 8:13
4

You already answered your own question, but this is a good place to note that Chrome (as of v12, currently in dev channel) has a built-in pretty-print function that can make quick work of the typical one-line JavaScript files that all well-behaved websites generate. In Web Inspector's Scripts tab, select a file via the usual dropdown, and right click on the source code. Selecting "De-obsfucate Source" will format the file in a reasonable way, and even allow you to set breakpoints inside the newly reformated code. It's quite helpful.

1
  • Cool. That does sound helpful. May 1, 2011 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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