Getting the cursor position in Addin Function


I’m trying to write an addin that will, given the location of a cursor, select the chunk code (i’m working with Rmarkdown).
That is

1:{r} 2:... 3. ... n:

If the user has their cursor somewhere between lines 1 and n, i will grab the selection corresponding to lines 2 … (n-1).

a) is there a keyboard shortcut corresponding to this? (note, R wont be the only engine, I’m using a custom engine)
b) if not, is there an rstudioAPI function to get the current cursor position in the document?


To answer (b), use primary_selection. it will return the cursr location.

Document Range:
- Start: [19, 13]
- End: [19, 13]

[1] ""