2

I like to trim whitespace with autocmd BufWritePre * :%s/\s\+$//e, but find myself often commenting out that line in .vimrc for certain file types. I'd like to write something like autocmd BufWritePre !*.patch :%s/\s\+$//e to suppress the autocmd for non-matching files, but that doesn't work. What's a good technique for expressing the negation of a pattern match?

William Pursell
  • 204,365
  • 48
  • 270
  • 300
  • https://stackoverflow.com/questions/6496778/vim-run-autocmd-on-all-filetypes-except – xdazz Jul 12 '17 at 08:40
  • 1
    For a robust plugin solution (that supports exceptions) have a look at my [DeleteTrailingWhitespace plugin](http://www.vim.org/scripts/script.php?script_id=3967). – Ingo Karkat Jul 12 '17 at 09:37

0 Answers0