Indent On New Lines In Console
<p>I have a large block of text. It has line breaks in it, but since the lines are still to long even with the line-breaks, it wraps to the next line. Since all of the other script functions have all lines indented one space, I would like this to match it. I understand that if I print just one line, I can just insert a space, and if I want to indent after a linebreak that fit in one line, I can just insert <code>\n</code> with a space after it.</p>

<p>How would I make every line in a block of text indent? e.g:</p>

<p><code>text = """This is a block of text. It keeps going on
           and on and on. It has some line breaks \n
           but mostly just keeps going on without
           breaks. The lines are sometimes too long,
           so they wrap to the next line, but they 
           don't indent. I need to fix this"""</code></p>

<p>that would print as:</p>

<pre><code>&gt;&gt;&gt; print(text) 
  This is a block of text. It keeps going on
  and on and on. It has some line breaks

  but mostly just keeps going on without
  breaks. The lines are sometimes too long,
  so they wrap to the next line, but they 
  don't indent. I need to fix this
</code></pre>

<p>Is this what you are looking for?</p>

<pre><code>import textwrap
from string import join, split

text = """This is a block of text. It keeps going on
            and on and on. It has    some line breaks \n
            but mostly just keeps going on without
            breaks. The lines are sometimes too long,
            so they wrap to the next line, but they 
            don't indent. I need to fix this"""

print "\nPrinted as one line:\n"
t=join(text.split())
print t

print "\nPrinted as formatted paragraph:\n"
t=join(text.split())
t=textwrap.wrap(t,width=70,initial_indent=' '*4,subsequent_indent=' '*8)
t=join(t,"\n")
print t
</code></pre>

<p>Results:</p>

<pre><code>Printed as one line:                                                                                                                                           

This is a block of text. It keeps going on and on and on. It has some line breaks but mostly just keeps going on without breaks. The lines are sometimes too lo
ng, so they wrap to the next line, but they don't indent. I need to fix this                                                                                   

Printed as formatted paragraph:                                                                                                                                

    This is a block of text. It keeps                                                                                                                          
        going on and on and on. It has                                                                                                                         
        some line breaks but mostly just                                                                                                                       
        keeps going on without breaks.                                                                                                                         
        The lines are sometimes too                                                                                                                            
        long, so they wrap to the next                                                                                                                         
        line, but they don't indent. I                                                                                                                         
        need to fix this                                                                                                                                       
</code></pre>

python console auto-indent