What is the minecraft command to kill all mobs except players and villagers? [duplicate]

I want to make a command block to make sure that anything that spawns in a village, dies, except players and villagers. Please help me.


Solution 1:

Since 1.13 you can use multiple of the same argument in one selector:

/kill @e[type=!player,type=!villager]