title: How can I set Emacs tab settings by file type?
body: <p>I need to be able to set the tab settings for the following file types:</p>
  
  <ul>
  <li>.rb: 2 soft spaces</li>
  <li>.css, .html.erb: 4 space tabs</li>
  </ul>
  
  <p>I have tried the following, but none of it seems to alter my default tab settings for each of the file types.</p>
  
  <pre><code>;; js-mode-hook has also been tried
  (add-hook 'javascript-mode-hook 
        '(lambda() 
          (setq tab-width 4)))
  
  (add-hook 'css-mode-hook 
        '(lambda() 
          (setq tab-width 4)))
  
  (add-hook 'html-mode-hook 
        '(lambda() 
          (setq tab-width 8)))
  </code></pre>
  
  <p>I am pretty new to emacs so my knowledge of configuration is pretty low.</p>