I just want to define an autocommand that executes some external commands. For example, delete some auto-generated files after compilation. I work on both Windows and Linux, and the external commands used are different on these two platforms.
Therefore, I can define:
if has("win32")
autocmd foo bar_win
else
autocmd foo bar_nix
endif
If I want to define this autocommand within a augroup
, should I simply put this piece of code into an augroup like:
augroup fooo
autocmd!
if has("win32")
autocmd foo bar_win
else
autocmd foo bar_nix
endif
augroup END
I tried this method, and it seems this works. I am wondering if this is the correct way to do it. Another way I can think about is to write the external commands into a function within which I can use if
statement. Then define autocommand in the usual way and call this function. Which is better?
Thanks!