Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to wrap long code lines in google-code-prettify

I'm using default setting of google-code-prettify. When a line is too long, it exceeds the boundary, like the following: enter image description here Are they any possible solution to wrap the code line?

like image 352
Ryan Avatar asked Mar 22 '14 21:03

Ryan


People also ask

How do you wrap a long line in VS Code?

You can toggle word wrap for the VS Code session with Alt + Z (macOS: Option (or Alt) ⌥ + Z ) or select View > Word Wrap from Menu.

What is word wrap column in VS Code?

Word Wrap (Controls how lines should wrap) Word Wrap Column (Controls the wrapping column of the editor) Wrapping indent (Controls the indentation of wrapped lines)


3 Answers

You need to use pre-wrap.

pre {
  white-space: pre-wrap;
}
like image 81
Dustin Poissant Avatar answered Oct 18 '22 23:10

Dustin Poissant


You can use the CSS property word-wrap: break-word; to enable word-wrapping. Make sure that your selector has priority over Google's style, as they probably set word-wrap: nowrap; somewhere.

like image 31
tvkanters Avatar answered Oct 19 '22 00:10

tvkanters


For anyone using linenums you need this

:not(pre) > code {
    white-space: pre-wrap; 
    word-wrap: break-word;
}
like image 2
Preston Avatar answered Oct 18 '22 23:10

Preston