javascript - codemirror : how to indent the whole line when pressing tab? -



javascript - codemirror : how to indent the whole line when pressing tab? -

i creating new simple mode codemirror.

i when user presses "tab", whole line gets indented (as opposed part of line after cursor, "splitting" line in two).

what simplest way ?

note : corresponding code not have defined in mode. other approach (e.g. add together on or configuration) work well.

this should work. jsfiddle

extrakeys: { "tab": function(cm){ // cursor position var pos = cm.getcursor(); // set cursor position begining of line. cm.setcursor({ line: pos.line, ch: 0 }); // insert tab cm.replaceselection("\t", "end"); // set cursor position original. cm.setcursor({ line: pos.line, ch: pos.ch + 1 }); } }

javascript codemirror codemirror-modes

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -