5

Sometimes, Mathematica starts a new line of code, even though there is still enough space. For example, I have:

  ( metricMatterODEReducedCSSNωV[[3]] = 
            FullSimplify[
Denominator[metricMatterEqnReducedCSSSolVx] V'[x] - 
 Numerator[metricMatterEqnReducedCSSSolVx]]) /. 
pp

where the Zoom has been set to 150%.

Lowering the Zoom makes it work of course. However, weirdly enough, removing the parentheses "()" removes this line break (I can still add quite a few more characters before it breaks (correctly this time) again). Alternatively, putting a ";" at the end also "pulls" the "pp" back to the upper line.

Why is this happening and how can I prevent this?

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
Patrick.B
  • 1,399
  • 5
  • 11
  • Related: https://mathematica.stackexchange.com/questions/24556/open-source-intellij-idea-plugin-to-support-mathematica-development – Michael E2 Feb 04 '19 at 01:40
  • 1
    Perhaps you want something like the "Code" style. If you set PageWidth->Infinity for the "Input" style, you do not get the line wrapping. You have to manually hit return where you want line breaks. You can get that functionality on a cell-by-cell basis with the menu Format > Word Wrapping > Don't Word Wrap. – Michael E2 Feb 04 '19 at 01:53

1 Answers1

4

The front-end's code editor has many quirks. Line breaking is where a lot them live. On the whole I think the editor does a pretty good job, but I know a lot of people disagree with me on that.

Aa well as window's magnification, window width also affects the line breaking. I'm running V11.3 on macOS 10.13.4. I always set my front-end windows to a width of 800 pixels. So I get something different than what you show.

window

Parentheses seem to encourage the code editor to break early. Sometimes adding a space just before a forced line break will get rid of it; sometimes not. Here is an example where it happens to work:

work_around

The upper code snippet shows a line break inserted by the editor when there was still plenty of space remaining on the line. The lower code snippet shows a space inserted after the semicolon the ends the line. As you can see, doing so removed the forced linebreak.

m_goldberg
  • 107,779
  • 16
  • 103
  • 257