Create shortcut to insert tilde or backticks

Hello, I feel this is kind of a stupid question, but I'm stuck. I work using a laptop with an Italian keyboard layout and no keypad. The layout does not include the tilde or the backtick characters, and haven't found a decent workaround for this, so everytime I need to insert these character I have to switch to the US layout, type, and go back to the Italian layout, or copy/paste. Is there a way to assign these character to a shortcut like CTRL+ALT+^? Or any other solution to the problem? Thanks!

Does this help:

https://stackoverflow.com/questions/31015152/how-to-type-tilde-in-r#:~:text=AltGr%20%2B%20^%20will%20give%20you%20a,were%20using%20in%20the%20comments.&text=You%20could%20use%20this%20variable%20when%20you%20need%20tilde%20in%20text.&text=Alternately%2C%20you%20could%20just%20type,copy%20and%20paste%20the%20character.

Thank you, but the first solution in that post is relevant for Mac OS or Linux, and the second is a bit complicated and is not suitable for beginners. As I use R to teach statistics 101, I'd like something really easy and working on Windows (I personally don't like it, but that's what most of my students use).

Maybe this.

Thanks, I'll give it a try... although it looks like it remaps a key to another key, so not having any key for tilde or backtick in my layout I am not sure it will work. If it does, it will permanently substitute the key, so the original character will be no more available.

If it's just RStudio you're concerned with, you can install the Remedy add-in, and then assign a shortcut to its "Insert backticks" function.
Or check out this already existing, customisable package: Add keybinding for %<>% magrittr pipe operator

Or write your own add-in, it can be quite simple like this (not tested):

#' Insert Backtick
#'
#' @importFrom rstudioapi insertText
#'
#' @return None
#'
insertBacktick <- function() {
  rstudioapi::insertText("`")
}

(you then also need a inst/rstudio/addins.dcf file - you have to make a simple package I think). Then assign a shortcut to that add-in function.

That seems a viable option. I'll try it and let you know. Thanks!

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.