Sunday, February 23, 2014

Negated autocmd filetype match

I have a function that strips trailing whitespace on save. In my .vimrc I have the line

autocmd BufWritePre * if &ft =~ 'sh\|perl\|python\....' | :call <SID>StripTrailingWhitespaces() | endif

What I would like is to negate that into matching everything but "condition".

This works OK for known filetypes:

autocmd BufWritePre * if &ft !=# 'text' | :call <SID>StripTrailingWhitespaces() | endif

but I also want to match when filetype is not set. I have tried various with no luck.

I was also advised to use:

autocmd FileType * if <amatch> !=# 'text' | ...


but can't see how that is correct, nor can I get it to work.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment