Key shortcut for '->'


I use alt + '-' for ' <- ' all the time, and I especially love it because it adds the spaces before and after itself.

I know of no shortcut for its left-to-right counterpart, i,e. ' -> '.

Something like shift+alt+'-' seems like a good choice.

My question: Can I create new key shortcuts? I know I can modify existing ones, but I don't know how, or if, I can create new ones.


Right now, the way to create new text insertions that can be mapped to keyboard shortcuts is via RStudio Addins (a couple of examples of Addins that exist to provide keyboard shortcuts for syntax: remedy and mufflr).

I haven't used it myself, but spAddins seems to provide the forward arrow: There may be other packages that include it, as well.

Another option is to use a code snippet, though for something this short, the returns may be diminishing! Still, you could at least give it a completion tag that keeps your fingers on your home row. For example, with my US keyboard layout, defining a snippet as:

snippet fa

and invoking it with fatabtab is less annoying than typing — but YMMV!


I think that some R users discourage the use of the right assignment. In any event, it is rather little used. That might explain the lack of a shortcut in RStudio (creating a shortcut might encourage its use).

Though that does not answer your question. For this, I totally second jcblum's suggestion to use a snippet. Snippets are wonderful and overlooked :slight_smile: