Complex sentence: He was educated at Cupar grammar school, where he was a contemporary of the artist Sir David Wilkie, and studied medicine at St Andrews University from 1796 until 1798 and the University of Edinburgh from 1798 to 1801.
Split into simpler sentences: He was educated at Cupar grammar school, where he was a contemporary of the artist Sir David Wilkie. He studied medicine at St Andrews University from 1796 until 1798 and the University of Edinburgh from 1798 to 1801.