Grind the onions, garlic, chilies and kaffir lime leaves together to a coarse paste. You should still be able to see bits and pieces of the chilies and lime leaves.
Heat a pan with the cooking oil to medium heat.
Add the ground paste.
Add the roasted or fried peanuts and anchovies. and stir through.
Add the fish sauce, vinegar and sugar according to taste.
Cool to room temperature before serving.