Skip to main content
2 of 10
added 656 characters in body
Alexey Popkov
  • 62.3k
  • 7
  • 154
  • 375

Is there any way to Print without suffering form auto-scrolling in the front end?

You can define a custom myPrint function with AutoScroll -> False:

myPrint[expr_] := 
 NotebookWrite[EvaluationNotebook[], 
  Cell[BoxData@ToBoxes@expr, "Print"], AutoScroll -> False]

As it is noted in the comments, with this version clicking anywhere inside of the Notebook may result in changing the insertion point and further outputs will be printed starting from the new location. Also there are issues with evaluation of multiple cells at once. Here is an improved version which binds the printing to the EvaluationCell[] and as a result prints in the reverse order (what may be desirable in some situations):

myPrint[expr_] := (
  SelectionMove[EvaluationCell[], After, CellGroup, AutoScroll -> False];
  NotebookWrite[EvaluationNotebook[], 
   Cell[BoxData@ToBoxes@expr, "Print"], AutoScroll -> False])
Alexey Popkov
  • 62.3k
  • 7
  • 154
  • 375