One of Edinburgh's greatest virtues is its compact size, which means that it is possible to pack a fair bit into even the briefest of visits. The two main areas of interest are the Old Town and the New Town, where you'll find Edinburgh Castle, the Scottish Parliament, Princes Street Gardens, and the National Gallery of Scotland. You can cover all four attractions in one day, but two days is more realistic. You can also choose between the Palace of Holyroodhouse and the important museums of Edinburgh, as well as entertaining sights such as the Real Mary King's Close, or explore the Royal Botanic Gardens and Holyrood Park. Head down to leafy, villagelike Stockbridge, then immerse yourself in the greenery along the Water of Leith, visiting the Gallery of Modern Art along the way.
Getting out of town is also an option for stays of more than a few days, depending on your interests: hop on a bus out to Midlothian to see the magnificent Rosslyn Chapel at Roslin (it's of interest to more than Da Vinci Code fans), and visit Crichton Castle, parts of which date back to the 14th century. Consider spending another half day traveling out to South Queensferry to admire the Forth rail and road bridges; then visit palatial Hopetoun House, with its wealth of portraits and fine furniture.