I can use autocmd to make my cmd to run if file of specific file type loaded. For example for python:
autocmd FileType python make me happy with python
But is there any way to make my cmd to run if loaded file is NOT of specific type? Something like:
autocmd FileType !python make me happy without python
example above doesn't work and autocmd!
will remove autocmd.
Any suggestions? Thanks.
There are several possibilities:
*
pattern and call your code only inside an if condition checking the filetype (something similar to this):
autocmd Filetype * if &ft!="python"|put your code here|endif
:autocmd FileType [^p],[^p][^y],[^p][^y][^t],[^p][^y][^t][^h],[^p][^y][^t][^h][^o],[^p][^y][^t][^h][^o][^n] :put your code here
(the last part is untested and should illustrate, why usually any of the other possibilities are used).
You can make an autocmd
which triggered by all (*
) filetype, then call a function.
In the function, you can check the ft
option (&ft
) to decide what should be done for certain filetype. There you can do any matching logic with the value of &ft
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With