Mma's output cells are by default in StandardForm. While this has obvious advantages, sometimes it can get annoying, for example when I wish to copy paste the output. When this happens, I usually manually right-click the cell and convert it to InputForm.

But is it possible to set these output cells to be in InputForm by default? Because under Preferences -> Evaluation -> Format type of new output cells I can only see three possibilities: StandardForm, TraditionalForm and OutputForm.

  • $\begingroup$ Why not just use Copy As > Input Text, either from the Edit menu or the (left-click) context menu? $\endgroup$ – m_goldberg Mar 13 '15 at 17:26
  • $\begingroup$ @m_goldberg First, because, for example, the constant Pi gets copied as \[Pi] this way, as opposed to converting it to InputForm, when it gets copied as Pi. Second, because I was wondering if there is any auto solution, that wouldn't require any extra clicking... $\endgroup$ – gaazkam Mar 13 '15 at 17:29

You can use $PrePrint to achieve this:

$PrePrint = InputForm;

Now every output will be preprocessed by InputForm before it is printed.

$PrePrint =.;

to restore the default behavior.
You could also use $Post instead of $PrePrint. However, when $Post is used you'll get Null as an output when there normally is no output, e.g. if the input ended with ;.

  • $\begingroup$ Many thanks! Out of curiosity: what's the difference between $PrePrint and $Post? Because from what I read in the documentation, they seem pretty much the same... $\endgroup$ – gaazkam Mar 13 '15 at 17:36
  • $\begingroup$ @gaazkam I thing $PrePrint is the better choice. Please see my edit why. $\endgroup$ – Karsten 7. Mar 13 '15 at 17:54

I think a cleaner way to achieve this would be:

SetOptions[$Output, FormatType -> InputForm];
  • $\begingroup$ This method produces an odd placing of the output (example), as it's printed before the Outs, which appear empty. Nevertheless +1. $\endgroup$ – Karsten 7. Oct 4 '15 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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