Melt butter in a medium frying pan on medium heat. Sauté onions until just tender (3-4 minutes). Stir in vinegar, sugar and rosemary/thyme. Cook, stirring occasionally, for a further 10-15 minutes, until onions are sticky and caramelised. Remove from heat and season with salt and pepper to taste.
Spread both sides of the bread with butter. Top half of the bread with caramelised onions and a generous quantity of cheese. Season with cracked pepper. Sandwich together with the remaining bread.
Toast in a toasted sandwich maker or frying pan until bread is golden and cheese has melted. Serve immediately.