Vim run autocmd on all filetypes EXCEPT

后端 未结 5 1825
悲哀的现实
悲哀的现实 2020-12-02 07:55

I have a Vim autocmd that removes trailing whitespace in files before write. I want this almost 100% of the time, but there are a few filetypes that I\'d like it disabled. C

5条回答
  •  猫巷女王i
    2020-12-02 08:30

    The easiest way would be to set a local variable for the one filetype to true. Then set the automcommand if that variable is false (if set for everything else) or if it exists at all (no need to preset it).

    autocmd BufWritePre *.foo let b:foo=true
    
    if !exists("b:foo")
        autocmd ...
    endif
    

    changed variable prefixes based on comment

提交回复
热议问题