Combine the vinegar and sugar in a small saucepan over medium heat. Cook, stirring, until the sugar dissolves, about 2 minutes. Remove from the heat and let cool.
Heat the oil in a large heavy saucepan over medium-high heat. Add the onions and cook, stirring occasionally, until softened, about 3 minutes. Add the garlic and stir until fragrant, about 30 seconds. Add the eggplant and salt and cook, stirring occasionally, until the eggplant is softened, about 6 minutes. Add the tomatoes and cook, stirring occasionally, until the caponata thickens, about 12 minutes.
Add the olives and pine nuts. Stir in the vinegar mixture, a tablespoon at a time, until the desired flavor and consistency is reached (the caponata mixture should be sweet-and-sour and not too thin). Stir in the basil. Adjust the seasoning with salt if necessary, and serve warm or chilled.
Yield: about 5 cups