title: Use Vim Retab to solve TabError: inconsistent use of tabs and spaces in indentation?
body: <p>Apologize for the newbie question, but I have read the manual, <a href="https://stackoverflow.com/questions/1024435/how-to-fix-python-indentation">this</a> question, and tried several times without results I expected. </p>
  
  <p>So I was using vim to edit a file (attached). But when running, I got the TabError: inconsistent use of tabs and spaces in indentation error.</p>
  
  <p>Here is what I have tried:</p>
  
  <ul>
  <li>Open the file with Vim. type <code>:retab</code>, and <code>:x</code>. Run the file again. Still got the TabError message.</li>
  <li>Open the file again and type <code>:retab!</code> and <code>:x</code>. Run the file again. Still got the TabError message.</li>
  <li>Open the file again and type <code>:retab! 4</code> and <code>:x</code>. Run the file again. This time it works but I have no idea why? Plus, in the files indentation seems excessively long. (I read <a href="https://stackoverflow.com/questions/5685406/inconsistent-use-of-tabs-and-spaces-in-indentation">here</a> that the editor might display 8 spaces for a tab)</li>
  </ul>
  
  <p><strong>My questions are:</strong></p>
  
  <ul>
  <li><p>What does <code>:retab</code>, <code>:retab!</code>, and <code>:retab! 4</code> mean?</p></li>
  <li><p>Why doesn't <code>:retab</code> work on my file?  </p>
  
  <pre><code>#!/usr/bin/env python
  #Reduce function for computing matrix multiply A*B    
  #Input arguments:
  #variable n should be set to the inner dimension of the matrix product (i.e., the number of columns of A/rows of B) 
  import sys
  import string
  import numpy
  
  #number of columns of A/rows of B
  n = int(sys.argv[1]) 
  
  #Create data structures to hold the current row/column values (if needed; your code goes here)
  
  currentkey = None
  alist = [] # list for elelents in  A
  blist = [] # list for elements in B
  # input comes from STDIN (stream data that goes to the program)
  for line in sys.stdin:
      #Remove leading and trailing whitespace
      line = line.strip()
      #Get key/value 
      key, value = line.split('\t',1)
      print(key, value)
      #Parse key/value input (your code goes here)
      key = (key.split(',', 1)[0], key.split(',',1)[1])   
      value = (value.split(',', 1)[0], value.split(',',1)[1], value.split(',',1)[2])  
      #If we are still on the same key...
      if key==currentkey:
          #Process key/value pair (your code goes here)
          # store all values in a lisl
          if value[0]=='A':
          alist.append([value[1], value[2]])
          else:
          blist.append([value[1], value[2]])
          #Otherwise, if this is a new key...
      else:
      #If this is a new key and not the first key we've seen, i.e. currentkey!=None
          if currentkey:
      #compute/output result to STDOUT (your code goes here)
          alist = sorted(alist)
          blist = sorted(blist)
          newlist = [a[1]*b[1] for a,b in zip(alist, blist)]
          res = newlist.sum() 
          print(currentkey, res)
          currentkey = key
          #Process input for new key (your code goes here)
  </code></pre></li>
  </ul>