Reputation: 51
Is there a way that I can force line break when user tries to type any character after column 80 for a document in code mirror.
Also optionally for indent on the next line
Upvotes: 1
Views: 832
Reputation: 1720
Yes, there is a way to do that. On cursor activity, test if current character index is 80 or over. if so, replace selection with new line "\n" . but do you really want to do that? break a word in half?
editor.on("cursorActivity" ,function(editor){
currentChar = editor.getCursor().ch
if (currentChar >= 80){
editor.replaceSelection("\n" ,"end")
}
})
Upvotes: 1