Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to span one expression across multiple cells? E.g. long if statement or function evaluation. I looked in documentation and searched forum/google and could not find.

share|improve this question
I don't think so. But given that you can format the expression inside the cell using the enter key, what would be the use of multiple cells? – celtschk Apr 15 '14 at 15:41
Multiple cells for collapsable regions of code and text – denfromufa Apr 17 '14 at 4:34
One option would be to factor out some of the code into separate definitions. If your code is so long that you would like to collapse parts of it, then doing so is probably a good idea anyway. – celtschk Apr 17 '14 at 8:23
in Visual Studio you can add #region ... #endregion collapsable parts of the code – denfromufa Aug 29 '15 at 2:49
sometimes it is not possible to factor out into smaller pieces due to logic or performance – denfromufa Aug 29 '15 at 2:50
up vote 5 down vote accepted

No, this is not possible. A cell can only be evaluated if it contains a complete and syntactically correct expression.

You might want to try Code style cells (Alt-8 or Command-8) which contain plain text and allow arbitrary formatting with spaces, tabs and newlines.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.