Question

I'm struggling to correct a behaviour with the CodeMirror editor in which a whole paragraph is recognized as a single line within a set of PRE tags. By pressing the HOME or END buttons on the keyboard I either get navigated to the start of the paragraph or end of the paragraph regardless of how many lines that paragraph might span.

On the Editors extraKeys property I overrode the Home button as follows:

extraKeys : {
  "Home" : function(instance){
      console.log(instance);
   }
}

However, even though I have a paragraph that extends over 15 lines, only a single set of PRE tags are found so according to CodeMirror there is only a single line in the editor.

Does anyone know of a way to bypass this so that the HOME/END buttons work as intended? I have tried the built in "goLineStart" and "goLineStartSmart" functions but they both go to the start of the paragraph

Was it helpful?

Solution

If you're meaning that they should take wrapping into account (go the start of the wrapped part of the line), you can bind Home and End to the "goLineLeft" and "goLineRight" commands to get the behavior you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top