Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to dynamically switch modes with CodeMirror?

Tags:

codemirror

How to dynamically switch modes with CodeMirror?

I have the default set, but need to switch it.

like image 275
Shamoon Avatar asked May 25 '11 20:05

Shamoon


1 Answers

Something like this would help you.

First, set CodeMirror:

this.editor = CodeMirror.fromTextArea(document.getElementById("textAreaCodeMirror"), {
    lineNumbers: true,
    matchBrackets: true,
    styleActiveLine: true,
    theme:"eclipse",
    mode:language
});

Then, to change the mode

this.editor.setOption("mode", language);
like image 59
Ponmudi VN Avatar answered Sep 28 '22 10:09

Ponmudi VN