How to reset Codemirror editor?

sthomps picture sthomps · May 4, 2013 · Viewed 10.6k times · Source

I would like to reset all the contents of the Codemirror editor. Ideally, this should clear the textarea, remove all marks and clear the history.

What's the best way to achieve this?

Answer

Alexander Pavlov picture Alexander Pavlov · May 17, 2013
cm.setValue("");
cm.clearHistory();
// cm.clearGutter("gutterId"); if you have gutters