title: How to set two autocmd BufWritePre in .vimrc
body: <p>On save/write in VIM I want to trim trailing whitespace and ensure that the file's line endings are UNIX and not DOS.</p>
  
  <p>Both of these commands work on their own, but I can't figure out how to get them to BOTH run on write/save of a file in VIM.</p>
  
  <pre><code>autocmd BufWritePre,FileWritePre * :%s/\s\+$//e
  autocmd BufWritePre,FileWritePre * :%s/\r$//
  </code></pre>
  
  <p>I've tried all of the following and still VIM throws errors:</p>
  
  <pre><code>autocmd BufWritePre,FileWritePre * :%s/\s\+$//e|:%s/\r$//
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>autocmd BufWritePre,FileWritePre * %s/\s\+$//e|%s/\r$//
  </code></pre>
  
  <p>AND</p>
  
  <pre><code>augroup prewrites
      autocmd!
      autocmd BufWritePre,FileWritePre * :%s/\s\+$//e
      autocmd BufWritePre,FileWritePre * :%s/\r$//                                                                                             
  augroup END 
  </code></pre>
  
  <p>None of these produce the desired result without errors being thrown by VI. Any help?</p>