5
$\begingroup$

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.

$\endgroup$
2
  • $\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, 2015 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, 2015 at 17:29

2 Answers 2

5
$\begingroup$

You can use $PrePrint to achieve this:

$PrePrint = InputForm;

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

$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 ;.

$\endgroup$
2
  • $\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, 2015 at 17:36
  • $\begingroup$ @gaazkam I thing $PrePrint is the better choice. Please see my edit why. $\endgroup$
    – Karsten7
    Mar 13, 2015 at 17:54
5
$\begingroup$

I think a cleaner way to achieve this would be:

SetOptions[$Output, FormatType -> InputForm];
$\endgroup$
3
  • $\begingroup$ This method produces an odd placing of the output (example), as it's printed before the Outs, which appear empty. Nevertheless +1. $\endgroup$
    – Karsten7
    Oct 4, 2015 at 16:38
  • $\begingroup$ How do I undo this? $\endgroup$
    – Kvothe
    Mar 11, 2022 at 15:27
  • $\begingroup$ @Kvothe SetOptions[$Output, FormatType -> StandardForm] to undo. $\endgroup$ Jul 26, 2022 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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