5

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.

gaazkam
  • 817
  • 5
  • 15
  • Why not just use Copy As > Input Text, either from the Edit menu or the (left-click) context menu? – m_goldberg Mar 13 '15 at 17:26
  • @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... – gaazkam Mar 13 '15 at 17:29

2 Answers2

5

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

Karsten7
  • 27,448
  • 5
  • 73
  • 134
  • 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... – gaazkam Mar 13 '15 at 17:36
  • @gaazkam I thing $PrePrint is the better choice. Please see my edit why. – Karsten7 Mar 13 '15 at 17:54
5

I think a cleaner way to achieve this would be:

SetOptions[$Output, FormatType -> InputForm];
Thomas Baruchel
  • 216
  • 2
  • 5