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
Post a Comment