How to get cursor location?

I have a scenario where I have to insert some lines at a specific location(this location is determined by where my cursor is in the editor). How to get the cursor location?

PS: When I refer to the cursor I am not referring to the mouse cursor but the cursor in the text editor.

That’s view.state.selection (and for the head of the main selection range, view.state.selection.main.head)

1 Like

That worked. Thank you very much!