Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R : Using shortcuts to insert operators writes to a different file

I'm sharing a small but annoying issue that sometimes pops up when I'm using shortcuts to insert operators while working on a markdown file in R : the operator either does not get written, or even worse gets written on another file.

So let's say I am working on the file "report.rmd", and I want to insert the pipe operator using Ctrl+Maj+M, or the assignment operator using "Alt+-", and I have the file "test.R" opened. Well, I therefore type the aforementioned shortcuts and...nothing happens on my markdown file. But some nice operators that had nothing to do there get written on my test.R file.

The only way I found to solve this problem is to close and reopen RStudio (restarting unfortunately doesn't solve the issue).

While this is quite a minor problem, it's incredibly annoying. Did it ever happen to anyone of you, and if so do you know where it comes from and how to solve it?

Edit: Although I am still running into this issue (without being able to reproduce it consistently) I came into a somewhat lighter solution. Instead of restarting R, simply closing all tabs (closing just the problematic one doesn't work) solves the problem. I hope this helps narrowing down the possible origins of the problem.

like image 869
pegot Avatar asked Oct 26 '25 23:10

pegot


1 Answers

Short Answer

re-define the key combo to Ctrl+Shift+ \ , assuming this does not create a conflict

Background

I've had a similar problem for a while, too. In my case, the shortcut never works. I can not find the source. I even found a conflict with Ctrl+Shift+M assigned to 2 Editor functions.

Image:Screen Capture 2 conflicting hotkey assignments

However, a simple key reassignment of the one that is not the pipe operator ("Expand to Matching")

Image:screen capture showing the hotkey conflict solveddidn't solve the issue in my case.

Solution

Here's what did the job for me

I managed to assign a different combo (that hasn't been assigned yet) and that is comfortable enough in the sense of its location on the keyboard

  1. go to Tools → Modify Keyboard Shortcuts...
  2. In the filter box, write "Pipe"
  3. Direct the cursor to the text box showing the current shortcut, and press the new combo (e.g. Ctrl+Shift+ \ ), then Enter.
  4. Remember to hit Apply
  5. Make sure the new Combo isn't a duplicate of another command, by going back to step 1 and sorting the list by Shortcut, then scrolling down to find your new one. if there is an ovelap, consider changing one of them.
like image 51
playmobilmeister Avatar answered Oct 29 '25 15:10

playmobilmeister



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!