InsertLinebreaks["string"]
inserts newline characters into string to make a string in which no line is longer than 78 characters.
InsertLinebreaks["string",n]
inserts newline characters to make no line longer than n characters.
InsertLinebreaks
InsertLinebreaks["string"]
inserts newline characters into string to make a string in which no line is longer than 78 characters.
InsertLinebreaks["string",n]
inserts newline characters to make no line longer than n characters.
Details
- InsertLinebreaks inserts line breaks into a string to ensure lines do not exceed a specified width, making long text easier to read or display.
- InsertLinebreaks works by replacing whitespace with newline characters.
- If a single span of non-whitespace characters is longer than n characters, newlines will be inserted every n characters within the span.
Examples
open all close allBasic Examples (2)
Insert newlines to ensure no line is longer than 30 characters:
InsertLinebreaks["Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", 30]Words longer than the specified length will be broken:
InsertLinebreaks["Pneumonoultramicroscopicsilicovolcanoconiosis", 10]Scope (2)
Insert newlines to make a string with lines no longer than the default width (78 characters):
Style[text = InsertLinebreaks[IconizedObject[«Moby Dick»]], 10]StringLength[StringSplit[text, "
"]]Insert newlines to make a string with lines no longer than 50 characters:
Style[text = InsertLinebreaks[IconizedObject[«Moby Dick»], 50], 10]StringLength[StringSplit[text, "
"]]See Also
StringPartition StringInsert StringReplace PageWidth OutputForm Column
Function Repository: StringWrap
Related Guides
History
Text
Wolfram Research (2015), InsertLinebreaks, Wolfram Language function, https://reference.wolfram.com/language/ref/InsertLinebreaks.html.
CMS
Wolfram Language. 2015. "InsertLinebreaks." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/InsertLinebreaks.html.
APA
Wolfram Language. (2015). InsertLinebreaks. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/InsertLinebreaks.html
BibTeX
@misc{reference.wolfram_2026_insertlinebreaks, author="Wolfram Research", title="{InsertLinebreaks}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/InsertLinebreaks.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_insertlinebreaks, organization={Wolfram Research}, title={InsertLinebreaks}, year={2015}, url={https://reference.wolfram.com/language/ref/InsertLinebreaks.html}, note=[Accessed: 13-June-2026]}