Variant on aphorism "Study as if you were to live forever. Live as if you were to die tomorrow" pre-dating Gandhi, variously attributed to Isidore of Seville (c. 560 – 636), in FPA Book of Quotations (1952) by Franklin Pierce Adams, to Edmund Rich (1175–1240) in American Journal of Education (1877), or to Alain de Lille in Samuel Smiles's Duty https://books.google.com/books?id=33UzAAAAMAAJ&pg=PA363&dq=live+die+tomorrow+learn+forever&hl=en&sa=X&ved=0ahUKEwjd3s_2m57MAhWFMGMKHe-sAl8Q6AEIHDAA#v=onepage&q=live%20die%20tomorrow%20learn%20forever&f=false (1881).
The 1995 book "The good boatman: a portrait of Gandhi," states that Gandhi subscribed "to the view that a man should live thinking he might die tomorrow but learn as if he would live forever."
In his 2010 Boyer lecture Glyn Davis (Professor of Political Science and Vice-Chancellor of Melbourne University) attributes the quote to Desiderius Erasmus. "He [Erasmus] reworked Pliny to urge 'live as if you are to die tomorrow, study as if you were to live forever'. Many students obey the first clause - the best heed both."
There is a similar quote by Johann Gottfried Herder: "Mensch, genieße dein Leben, als müssest morgen du weggehn; Schone dein Leben, als ob ewig du weiletest hier." ["Man, enjoy your life as if you were to depart tomorrow; spare your life as if you were to linger here forever."] (Zerstreute Blätter, 1785).
Disputed