title: Remove messy leading whitespace in Vim on Mac OS X
body: <p>I am copying code from website <a href="http://matplotlib.sourceforge.net/" rel="nofollow noreferrer">matplotlib</a> and pasting into the Vim editor in a terminal on Mac OS X:</p>
  
  <p><a href="http://matplotlib.sourceforge.net/" rel="nofollow noreferrer">pylab_examples example code: ellipse_demo.py</a></p>
  
  <p>While this works fine in <a href="http://en.wikipedia.org/wiki/BBEdit" rel="nofollow noreferrer">BBEdit</a>:</p>
  
  <pre><code>`from pylab import figure, show, rand
  from matplotlib.patches import Ellipse
  
  NUM = 250
  
  ells = [Ellipse(xy=rand(2)*10, width=rand(), height=rand(), angle=rand()*360)
          for i in xrange(NUM)]
  
  fig = figure()
  ax = fig.add_subplot(111, aspect='equal')
  for e in ells:
      ax.add_artist(e)
      e.set_clip_box(ax.bbox)
      e.set_alpha(rand())
      e.set_facecolor(rand(3))
  
  ax.set_xlim(0, 10)
  ax.set_ylim(0, 10)
  
  show()
  </code></pre>
  
  <p>That is, all the code is properly aligned. In Vim it looks like this:</p>
  
  <pre><code>from pylab import figure, show, rand
  from matplotlib.patches import Ellipse
  
  NUM = 250
  
  ells = [Ellipse(xy=rand(2)*10, width=rand(), height=rand(), angle=rand()*360)
          for i in xrange(NUM)]
  
              fig = figure()
              ax = fig.add_subplot(111, aspect='equal')
              for e in ells:
                      ax.add_artist(e)
                          e.set_clip_box(ax.bbox)
                              e.set_alpha(rand())
                                  e.set_facecolor(rand(3))
  
                                  ax.set_xlim(0, 10)
                                  ax.set_ylim(0, 10)
  
                                  show()
  </code></pre>
  
  <p>How to fix this annoying situation? Does it have something to do with the different carriage return / line feed conventions on the Mac?</p>