Search code examples
javascriptcodemirror

Get Selected Range in Codemirror


If i select a piece of range in my codemirror editor with say shift+up/down/left/right , is there a way to get the co-ordinates of the piece of text selected ? Like the line num for start/end, the char positions relative to lines and also to document ?


Solution

  • codemirror.getCursor(true) will get you the start of the selection. codemirror.getCursor(false) will get you the end of the selection.