title: How to set a different colorscheme for each file type in Vim?
body: <p>In <strong><em>Vim</em></strong>, I want to use a different colorscheme for each file type.</p>
  
  <p><em>e.g.</em> I want to use <code>desert256</code> colorscheme for <em>Python</em> &amp; <em>JavaScript</em> files, and use <code>jellybeans</code> colorscheme for <em>HTML</em> &amp; <em>CSS</em> files.</p>
  
  <hr>
  
  <p>I've tried putting the following code in my <code>.vimrc</code>, but the colorscheme change happens <strong><em>only</em></strong> when changing buffers for the first time.</p>
  
  <p><em>i.e.</em> If I open a new <em>Python</em> file, <em>Python</em>'s colorscheme is used, and when I open a new <em>CSS</em> *buffer*, indeed the colorscheme changes to <em>CSS</em>'s colorscheme. However, Changing back to <em>Python</em>'s buffer does not change the colorscheme back.</p>
  
  <p>I've used <code>autocmd WinEnter</code> to try and make this rule happen when changing windows (and buffers), but it doesn't help:</p>
  
  <pre><code>autocmd WinEnter,FileType python,javascript colorscheme desert256
  autocmd WinEnter,FileType *,html,css        colorscheme jellybeans  " This includes default filetype colorscheme.
  </code></pre>
  
  <hr>
  
  <p>How can I fix this? In addition, a bonus would be to not change a colorscheme when not needed - <em>i.e.</em> Changing from a <em>Python</em> to a <em>JavaScript</em> buffer won't change the colorscheme to "itself".</p>
  
  <hr>
  
  <h2>EDIT:</h2>
  
  <p>If anyone's interested, <a href="https://github.com/oryband/dotvim">here is my <code>.vimrc</code> repo in github.com</a>. I'll update it with the solution I find here once given.</p>