(computer science) A procedure whereby a word processor automatically ends each line when it is full and starts the next line with the next word, never breaking a word. Also known as wrap mode.
| Sci-Tech Dictionary: word wrap |
(computer science) A procedure whereby a word processor automatically ends each line when it is full and starts the next line with the next word, never breaking a word. Also known as wrap mode.
| 5min Related Video: Word wrap |
| Computer Desktop Encyclopedia: word wrap |
A word processing feature that moves words to the next line automatically as you type based on the current right margin setting. Some word processing programs allow word wrap to be turned off for writing source code. Of course, for customized spacing, you can always press Enter for a hard return just as in the old typewriter days. See hard return.
Download Computer Desktop Encyclopedia to your iPhone/iTouch
| Business Dictionary: Word Wrap |
Feature of most Word Processing programs that causes the Cursor to proceed automatically from one line to the next when the end of the line is reached, taking the last word with it if necessary. In contrast to typing, the typist does not have to watch the screen and hit the return key at the end of each line.
| Wikipedia: Word wrap |
In text display, line wrap is the feature of continuing on a new line when a line is full, such that each line fits in the viewable window, allowing text to be read from top to bottom without any horizontal scrolling.
Word wrap is the additional feature of most text editors, word processors, and web browsers, of breaking lines between and not within words, except when a single word is longer than a line.
It is usually done on the fly when viewing or printing a document, so no line break code is manually entered, or stored.[citation needed] If the user changes the margins, the editor will either automatically reposition the line breaks to ensure that all the text will "flow" within the margins and remain visible, or provide the typist some convenient way to reposition the line breaks.
Compare soft return and hard return.
Contents |
The soft returns are usually placed after the end of complete words, or after the punctuation that follows complete words. However, word wrap may also occur following a hyphen.
Word wrap following hyphens is sometimes not desired, and can be avoided by using a so-called non-breaking hyphen instead of a regular hyphen. On the other hand, when using word processors, invisible hyphens, called soft hyphens, can also be inserted inside words so that word wrap can occur following the soft hyphens.
Sometimes, word wrap is not desirable between words. In such cases, word wrap can usually be avoided by using a hard space or non-breaking space between the words, instead of regular spaces.
In Chinese, Japanese, and Korean, each Han character is normally considered a word, and therefore word wrapping can usually occur before and after any Han character.
Under certain circumstances, however, word wrapping is not desired. For instance,
Most existing word processors and typesetting software cannot handle either of the above scenarios.
CJK punctuation may or may not follow rules similar to the above-mentioned special circumstances; such rules are usually referred to by the Japanese term kinsoku shori (禁則処理, literally “prohibition rule handling”).
A special case of kinsoku shori, however, always applies: line wrap must never occur inside the CJK dash and ellipsis. Even though each of these punctuation marks must be represented by two characters due to a limitation of all existing character encodings, each of these are intrinsically a single punctuation mark that is two ems wide, not two one-em-wide punctuation marks.
Word wrapping is an optimization problem. Depending on what needs to be optimized for, different algorithms are used.
A simple way to do word wrapping is to use a greedy algorithm that puts as many words on a line as possible, then moving on to the next line to do the same until there are no more words left to place. This method is used by many modern word processors, such as Microsoft Word and Open Office. This algorithm is optimal in that it always puts the text on the minimum number of lines. The following pseudocode implements this algorithm:
SpaceLeft := LineWidth
for each Word in Text
if Width(Word) > SpaceLeft
insert line break before Word in Text
SpaceLeft := LineWidth - Width(Word)
else
SpaceLeft := SpaceLeft - (Width(Word) + SpaceWidth)
Where LineWidth is the width of a line, SpaceLeft is the remaining width of space on the line to fill, SpaceWidth is the width of a single space character, Text is the input text to iterate over and Word is a word in this text.
A different algorithm, used in TeX, minimizes the square of the space at the end of lines to produce a more aesthetically pleasing result. The algorithm above is not optimal with respect to this, as the following example demonstrates:
aaa bb cc ddddd
If the cost function of a line is defined by the remaining space squared, the greedy algorithm would yield a sub-optimal solution for the problem (for simplicity, consider a fixed-width font):
------ Line width: 6 aaa bb Remaining space: 0 (cost = 0 squared = 0) cc Remaining space: 4 (cost = 4 squared = 16) ddddd Remaining space: 1 (cost = 1 squared = 1)
Summing to a total cost of 17, while an optimal solution would look like this:
------ Line width: 6 aaa Remaining space: 3 (cost = 3 squared = 9) bb cc Remaining space: 1 (cost = 1 squared = 1) ddddd Remaining space: 1 (cost = 1 squared = 1)
The difference here is that the first line is broken before bb instead of after it, yielding a better right margin and a lower cost 11.
To solve the problem we need to define a cost function c(i,j) that computes the cost of a line consisting of the words Word[i] to Word[j] from the text:
![c(i, j) = \left(\text{LineWidth}-\text{SpaceWidth}(j-i)-\sum_{k=i}^j \text{Width}(\text{Word}[k])\right)^P.](http://wpcontent.answers.com/math/8/0/b/80b430705a1464821815d3d4d65dd98c.png)
Where P typically is 2 or 3. There are some special cases to consider: If the result is negative (that is, the sequence of words cannot fit on a line), the cost needs to reflect the cost of tracking or condensing the text to fit; if that is not possible, it needs to return
.
The cost of the optimal solution can be defined as a recurrence:

This can be efficiently implemented using dynamic programming, for a time and space complexity of O(j2).
This entry is from Wikipedia, the leading user-contributed encyclopedia. It may not have been reviewed by professional editors (see full disclaimer)
| reflowable text (technology) | |
| Leff | |
| text editor (technology) |
| Computer word wrap occurs when? | |
| What are the words for the mc donalds wrap? | |
| How do you text wrap on microsoft word? |
Copyrights:
![]() | Sci-Tech Dictionary. McGraw-Hill Dictionary of Scientific and Technical Terms. Copyright © 2003, 1994, 1989, 1984, 1978, 1976, 1974 by McGraw-Hill Companies, Inc. All rights reserved. Read more | |
![]() | Computer Desktop Encyclopedia. THIS COPYRIGHTED DEFINITION IS FOR PERSONAL USE ONLY. All other reproduction is strictly prohibited without permission from the publisher. © 1981-2009 Computer Language Company Inc. All rights reserved. Read more | |
![]() | Business Dictionary. Dictionary of Business Terms. Copyright © 2000 by Barron's Educational Series, Inc. All rights reserved. Read more | |
![]() | Wikipedia. This article is licensed under the Creative Commons Attribution/Share-Alike License. It uses material from the Wikipedia article "Word wrap". Read more |
Mentioned in