Create Add-In that applies the function to the selected text.

I want an Add-In to apply `` with a shortcut key for referencing code more quickly using Rmarkdown.

I already created the following shortcut by applying:

insertInAddin <- function() {

But I want the Add-In to apply to the selected text, or make the cursor to position between the two automatically, when applying it, as it happens with ""