How can I make Firefox word-wrap text/plain files?

17

When I view this IRC log in Firefox, long lines do not wrap. But I wish they would! Anyone know how to make Firefox word-wrap text/plain files?

  • this file is served as gzipped plain text; try HEAD http://ci.mifos.org/irclogs/%23mifos/archive/2010/2010-01-04.log.gz and you should see Content-Type: text/plain
  • when the same resource is viewed in Google Chrome, long lines wrap
  • this might be a related question on doctype, but the "accepted answer" contains a broken link
  • this didn't work for me (even the alternate version using pre-wrap as opposed to -moz-pre-wrap mentioned in a comment by user "Idran")
  • using "View → Page Source", then toggling word wrap is a suitable workaround

Adam Monsen

Posted 2010-08-13T19:02:22.353

Reputation: 354

Answers

7

The Toggle Word Wrap Firefox extension might work for you.

Jarvin

Posted 2010-08-13T19:02:22.353

Reputation: 6 712

Adding an extension is not necessary. See answer below on making a simple change in about:config. – Paul – 2017-02-03T14:36:50.750

1Yes, that works! I noticed that plugin, but I dismissed it since the description only mentions PRE tags and HTML, so I assumed it wouldn't work for text/plain documents. Thank you! – Adam Monsen – 2010-08-13T22:35:50.977

I did that too. That is, dismissed the add-on because it focused on PRE tags. Thanks Dan! – nperson325681 – 2010-11-27T15:18:52.737

7

FF 31. Open a new tab.

Enter about:config in the Awesome Bar.

Search for view_source.wrap_long_lines and set value to true.

mdh42

Posted 2010-08-13T19:02:22.353

Reputation: 71

@Twisty The view_source.wrap_long_lines preference predates version 2. That was why I deleted the reference to FF31. – Paul – 2017-02-05T13:13:25.067

@Paul Removing the original answerer's mention of FF 31 is too drastic of an edit ("clearly conflicts with author's intent"), even if the poster is wrong. It would be better to either mention this information in a comment much as you've done, or construct the edit in a way that does not eliminate the original mention of FF 31. – I say Reinstate Monica – 2017-02-05T13:20:52.903

4

If you just need to wrap plaintext files, try Ctrl-U (then View -> Wrap Long Lines, if not already checked). This solution is cleaner than an add-in with plaintext files, but sloppier with text embedded in html.

Travis

Posted 2010-08-13T19:02:22.353

Reputation: 57

1As of at least FF 51, this option is not available. See answer further down explaining how to configure in about:config. – Paul – 2017-02-03T14:35:16.100

Not liking unnecessary plugins, this is a great solution! – sage – 2012-08-31T20:39:24.777

4

Go to the Firefox User Profile.

This is for applying a style to all web pages you view.

Firefox User Profile Folder --> Chrome -- > userContent.css (If this file is not present, make a copy of userContent-example.css and rename it!

/*
 * This file can be used to apply a style to all web pages you view
 * Rules without !important are overruled by author rules if the
 * author sets any.  Rules with !important overrule author rules.
 */

This is for customizing Mozilla's user interface.

Firefox User Profile Folder --> Chrome -- > userChrome.css (If this file is not present, make a copy of userChrome-example.css and rename it!

/*
 * This file can be used to customize the look of Mozilla's user interface
 * You should consider using !important on rules which you want to
 * override default settings.
 */

Add to the bottom:

pre { white-space: pre-wrap !important; }

Save the file.]

Restart Firefox. Works with Firefox 26.

GMan

Posted 2010-08-13T19:02:22.353

Reputation: 41

2

This answer is inspired by @Travis's answer.

If you just need to wrap plain text files, then on the menu bar click ViewPage StyleWrap Long Lines. This solution is cleaner than an add-on for plain text files, but sloppier with text embedded in HTML.

Screenshot of Firefox menu

Nathan

Posted 2010-08-13T19:02:22.353

Reputation: 1 050

1

Here is an untested possibility, but the ideal solution if using view-source:URL with [View] [wrap long lines] enabled. This would be for the text/plain mime type to automatically use:

view-source: schema

This avoids the ctrl-u or menu [page source] click and reduces manual labour in an automated computing environment.

ekim

Posted 2010-08-13T19:02:22.353

Reputation: 19

see @Travis’s answer

– chharvey – 2017-12-14T21:55:27.890

1

For what it's worth, Firefox 22 (the current target as of this writing) will introduce a new feature to allow wrapping text files directly in the browser. See improved plain-text handling in Firefox for a preview, and Firefox bug 253564 for the gory details.

Jonah Bishop

Posted 2010-08-13T19:02:22.353

Reputation: 429

Good information to know, but doesn't really answer the question or solve the problem. Comments along the lines of "it will be fixed soon; just upgrade" should be comments, not answers. – chharvey – 2017-12-14T21:52:31.647