# Pretty printing Ruby code

**URL:** <https://www.ruby-forum.com/t/pretty-printing-ruby-code/204024>\
**Category:** Ruby\
**Created:** [March 3, 2011, 5:10pm UTC](https://www.ruby-forum.com/t/pretty-printing-ruby-code/204024 "2011-03-03T17:10:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [March 3, 2011, 5:10pm UTC](https://www.ruby-forum.com/t/pretty-printing-ruby-code/204024/1 "2011-03-03T17:10:50Z")

</div>

Hi…

I wonder, what are your solutions for pretty printing Ruby code,  
as for printing on real paper, spreading it across a table  
and reviewing it and marking it with handwritten notes etc.

Currently I source highlight via enscript and do 4-on-1 like this:

cat bla.ruby |  
fold -w 89 |  
enscript -Eruby -c -B -h -p- -fCourier10 --margins=15:15:30:30 | pstops  
-pa4  
“4:1@.50(0.5cm,0.85cm)+3@.50(10.16cm,0.85cm)+0@.50(0.5cm,14.44cm)+2@.50(10.16cm,14.44cm)”

> output.ps

…but I guess you have also nice solutions to this problem?

Alternative recommendations welcome! 🙂  
Martin

---

<div class="post-metadata">

**Author:** ![dhstudio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b487fb/32.png) [@dhstudio](https://www.ruby-forum.com/u/dhstudio)\
**Post date:** [March 3, 2011, 5:16pm UTC](https://www.ruby-forum.com/t/pretty-printing-ruby-code/204024/2 "2011-03-03T17:16:28Z")

</div>

On Thu, Mar 3, 2011 at 4:10 PM, Martin P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi…
> 
> I wonder, what are your solutions for pretty printing Ruby code,  
> as for printing on real paper, spreading it across a table  
> and reviewing it and marking it with handwritten notes etc.

IIRC this is an area where most editors and IDEs excel at. Netbeans is  
what  
I used for printing Ruby code before, it doesn’t fuss much about any  
language really. Though I imagine most editors that do syntax  
highlighting  
will have a good print option as well.

regards,  
Richard

---

<div class="post-metadata">

**Author:** ![dhstudio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b487fb/32.png) [@dhstudio](https://www.ruby-forum.com/u/dhstudio)\
**Post date:** [March 21, 2011, 8:59pm UTC](https://www.ruby-forum.com/t/pretty-printing-ruby-code/204024/3 "2011-03-21T20:59:15Z")

</div>

Hi,

I use Latex with the listings package.

#include the package  
\usepackage{listings}

#set some nice print options and indicate the file  
\lstset{basicstyle=\footnotesize,language=Ruby}  
\lstset{linewidth=500pt}  
\lstset{numbers=left, stepnumber=1}  
\lstset{commentstyle=\color{blue},  
stringstyle=\color{green},showspaces=false}  
\lstset{keywordstyle=\color{red}\bfseries\emph}  
\lstset{frame=trBL,frameround=tttt}  
\lstinputlisting[caption=chromosome.rb,label=lst:lowertri]{./bin/rn\_practice.rb}

Kind regards,  
V.
