Detecting new line in codemirror
问题 Is there any way to detect a newline in codemirror editor, either when user hits enter or a line of code wraps? p.s: in the screenshot attached 3 new lines are created by user hitting enter key (228, 229, 230), and one line (between 229 and 300) is created because of line wrapping. screenshot here: http://s9.postimage.org/gsroinedp/Screen_Shot_2012_11_19_at_11_30_09_PM.png 回答1: Catching the enter key is built into the api. var editor = CodeMirror.fromTextArea(document.getElementById("code"),