Heat the oil in a large frypan over medium heat until it slides easily across the pan. Add onions, salt and pepper and cook, stirring occasionally, for about 20 minutes, until onions are soft.
Add sugar and reduce the heat to medium-low. Cook, stirring frequently, for about 10 minutes, until onions appear dry.
Add vinegar and reduce heat to low. Continue cooking, stirring occasionally, for about 1 hour, until onions are soft and dry. Serve warm or at room temperature. Store marmalade in refrigerator.
It will keep for several weeks.