title: How to edit .vimrc file to replace tab with spaces?
body: <p>I am writing a Python script which writes some formatted data into a YAML file. I am using tabs for formatting the text, but I want the tabs to be converted into spaces when written into the YAML file. This is because my YAML file does not take tabs as valid indentation tokens.</p>
  
  <p>I have tried this:</p>
  
  <p>Step 1: Go to your home directory</p>
  
  <pre><code>cd ~
  </code></pre>
  
  <p>Step 2: Create the file</p>
  
  <pre><code>vim .vimrc
  </code></pre>
  
  <p>Step 3: Add the configuration stated below</p>
  
  <pre><code>set smartindent
  
  set tabstop=4
  
  set shiftwidth=4
  
  set expandtab
  
  :retab
  </code></pre>
  
  <p>But this does not work. The YAML file created still has tabs. The tabs are not converted to spaces.</p>
  
  <p>Please suggest what changes should I make into my <code>.vimrc</code> file so that tabs are converted into spaces for valid indentation.</p>
  
  <p>The Python script:</p>
  
  <pre><code>template = open("/home/stack/horizon/openstack_dashboard/dashboards/mydashboard/mypanel/extracted_template.yaml","w")
  
  networks = api.neutron.network_list_for_tenant(self.request,tenant_id,params={}) 
  
  for n in range(0,len(networks)):
        n_name = networks[n]['name']
        print&gt;&gt;template,"\tprivate_net%d:"%n,"\n\t type: OS::Neutron::Net","\n\t properties:","\n\t  name:",n_name          
  </code></pre>