Heidelberg is the Germany people imagine before they see the real one: a red sandstone castle ruin on a wooded hill, a baroque old town squeezed along the Neckar, a stone bridge with twin towers and a hillside path where poets and philosophers are supposed to have walked. It mostly lives up to the picture, and it carries more history than the postcards let on: the ruin is not the work of one war, the university dates from 1386, and the city was almost completely spared by bombing in 1945, which is why the old town is still standing.
It's a small city, around 156,000 people and a large student population, so the ritual here is walking, climbing and sitting down for a long lunch. Three days covers the city properly. Five lets you add the Philosophenweg and the hills on the north bank, and use two days for the lands the Electors of the Palatinate once ruled: Schwetzingen's gardens, Speyer's cathedral and the wine villages on the Bergstraße.
The plan keeps each day in one part of town. Day one is the castle and the old town, day two the university and the student city, day three the north bank and the hills, day four a trip to Schwetzingen and Speyer, and day five a trip along the vineyards of the Bergstraße with a farewell dinner back in the old town. It's an easy first stop on a trip through Germany. If you can choose, start on a Tuesday: the university museum, the Palatinate Museum and the Prinzhorn Collection are all closed on Mondays, and the shops in the old town close on Sundays. Starting on another day works if you shuffle days one to three, but day five's farewell dinner at Zum Roten Ochsen only works on a Friday or Saturday. On any other night, swap it for the Kulturbrauerei or Vetter's.