Get the current line and column number from the cursor position

Hello, is there anyway to get line and column numbers of the cursor position? I am trying to show a panel that returns “Line X, Column Y” of the cursor position

state.doc.lineAt(state.selection.main.head)

1 Like

Thanks, it works but I haven’t solved yet.
I wrote
if (update.selectionSet)
dom.textContent = "Line “+EditorView.state.doc.lineAt(EditorView.state.selection.main.head).number+”, Column "+(EditorView.state.doc.lineAt(EditorView.state.selection.main.head).to-EditorView.state.doc.lineAt(EditorView.state.selection.main.head).from);

this returns “Line X, Column Y” where Y is not the column of the position of the selection, but the position of the last word i have written on that line. How can I get this to return the line and column of the position of the cursor (like in the cursor tooltip example)?

ok maybe this is the solution:

if (update.selectionSet)
dom.textContent = "Line “+EditorView.state.doc.lineAt(EditorView.state.selection.main.head).number+”, Column "+(EditorView.state.selection.ranges[0].head-EditorView.state.doc.lineAt(EditorView.state.selection.main.head).from)

1 Like

state.lineAt method does not seem exist

That should have said state.doc.lineAt, sorry.