Reputation: 2282
Recently the RStudio shortcut for the pipe operator %>%
stopped working. This appeared to have occurred randomly, as I didn't update anything. Does anyone know what is going on and how I might fix this?
> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_1.0.7
loaded via a namespace (and not attached):
[1] rstudioapi_0.13 knitr_1.34 magrittr_2.0.1 tidyselect_1.1.1
[5] R6_2.5.1 rlang_0.4.11 fastmap_1.1.0 fansi_0.5.0
[9] tools_4.1.0 xfun_0.25 utf8_1.2.2 cli_3.0.1
[13] DBI_1.1.1 htmltools_0.5.2 ellipsis_0.3.2 yaml_2.2.1
[17] digest_0.6.27 assertthat_0.2.1 tibble_3.1.3 lifecycle_1.0.0
[21] crayon_1.4.1 purrr_0.3.4 vctrs_0.3.8 glue_1.4.2
[25] evaluate_0.14 rmarkdown_2.10 compiler_4.1.0 pillar_1.6.2
[29] generics_0.1.0 pkgconfig_2.0.3
Upvotes: 9
Views: 7976
Reputation: 1604
I have had an ongoing problem with R Studio's default insert pipe shortcut key (Ctrl+Shift+M
) for a year or so. I had been unable to get the hot key combination to work, so I had settled on simply using Ctrl+Shift+N when I couldn't figure out what was interferring with the keyboard shortcut/hotkey. But I finally resolved the issue through some searching and patience, and I figured I'd try to help anyone else out with the process I went through to figure out and solve the problem. My narrative below isn't mean to be a succinct and step-by-step process to a potential resolution, but instead, simply shows the process I went through in hopes that someone can try to follow a similar process to resolve any keyboard shortcut that might be intererring with the Insert Pipe Operator shortcut or any other hotkey combination in R Studio.
Since I was able to assign a different shortcut key to the Insert Pipe command in R Studio, I knew the problem didn't lie within R or R Studio, but had to be some other program or windows assigned shortcut key interferring with Ctrl+Shift+M
. So I first tried installing and running the Hotkey Detective program discussed on Super User here and available on github here. When I ran the program, and pressed the shortcut keys, unfortunately, it simply indicated that the Process Path for the Ctrl+Shift+M
hotkey was C:\Windows\explorer.exe
. This wasn't much help, but it did indicate that some process was being triggred and running from explorer.exe
.
I figured I might find some information about the process by taking a look at my Winows 10 Event Viewer Logs. So I opened Event Viewer, clicked to expand Custom Views, and selected Administrative Events. I again, executed the hotkeys, refreshed the log, and sorted the logged entries to review the most recent logs. From there, I discovered, several PowerShell Warnings. Upon clicking one of these, I saw the following information in the log:
Severity=Warning
SequenceNumber=13
HostName=ConsoleHost
HostVersion=5.1.19041.3031
HostId=7fxxxxxxx-xxxx-<redacted>-xxxxxxxxxxx4d
HostApplication=Powershell `c:\MoveMouseHome.ps1`
EngineVersion=
RunspaceId=
PipelineId=
CommandName=
CommandType=
So it looked to me like a PowerShell script at c:\MoveMouseHome.ps1
was playing a role in the problem. To be certain, I executed the hotkey sequence several more times, refreshed the logs, and lo and behold, other similar log entries appeared pointing to c:\MoveMouseHome.ps1
. I knew at this point, I needed to home in on this ps1 file.
Next, I opened up the root of c:\
and took a look at MoveMouseHome.ps1 in a text editor. The .ps1 script was a program I vaguely remember writing two years ago. I have 8 monitors so sometimes my cursor can get lost in the screens, so I had written this script and assigned a hot key to it to reposition my cursor in the middle of my "home screen" to make it easy to find.
I right-clicked on MoveMouseHome.ps1
and clicked on properties to see if there I could find some hotkey assignemnt made to it. There was no such assignment there. But, after a bit of "Googling," I rediscovered that you can execute a powershell script from a hotkey by creating a windows file shortcut to the script and then assigning the file shortcut to the hotkeys. The only problem was I couldn't locate the shortcut after some cursory searching. Thankfully, I found this useful PowerShell script also on SuperUser.com which searches Windows for all shortcuts that have hotkeys assigned to them and displays them in the Powershell console. In the PS console under LinkPath
I saw the path to a shortcut I had created and the console indicated that Ctrl+Shift_M
was indeed assigned to that shortcut. Bingo!
Next, I simply navigated to the location of the shortcut file, then right-clicked properties, and under the Shortcut tab, I clicked on Shortcut key
text box (see image below), deleted the Ctrl+Shift+M
hotkey assignment (i.e., the Shortcut key
field was now assigned: none
) and clicked apply.
After that, I went back to R Studio->Tools->Modify Keyboard Shortcuts
and entered "Pipe" in the search/filter text box at the top to the screen, and then I re-assigned Ctrl+Shift+M
to Insert Pipe Operator
. I clicked Apply and swapped over to an R Script, held my breath, and punched in the hotkeys, and boom! The pipe operator was inserted as I had hoped. Problem solved!
Upvotes: 1
Reputation: 10061
I had the same problem once, please try Control + Shift + , as an alternative pipe operator, it works for my Windows 10 computer.
Upvotes: 0
Reputation: 21
For me it was Radeon software. Control + Shift + M is the hotkeys command for toggling the microphones. As soon as I clicked on unbind (technically I hit delete to ubind that shortcut), the shortcut for pipe worked in R Studio again. So if you don't have webex might try this or look into other apps. I saw that Teams uses the same combo to mute/unmute. FYI.
Upvotes: 2
Reputation: 2282
It appears that many people are having this issue across R and RStudio versions (https://community.rstudio.com/t/ctrl-shift-m-pipe-operator-shortcut-is-suddenly-stop-working-since-this-morning/118362), and may be due to a conflict with the default Ctrl+Shift+M being a shortcut for another process (seems to be "mute" in WebEx for many; see comments and other answers below).
In your RStudio IDE if you go to the "Tools" tab and select "Modify Keyboard Shortcuts..." you can see a list of shortcuts. If you type "pipe" into the search bar at the top, you will see that "Insert Pipe Operator" is still set to Ctrl+Shift+M, yet it does not work.
The simple solution that I chose is to click on this "Ctrl+Shift+M", once highlighted, type in a new shortcut by pressing the keys you would use for that shortcut (although there is likely a more elegant solution than changing your shortcut).
I chose "Ctrl+Shift+," since the comma is only one space away from M on my keyboard.
Upvotes: 11
Reputation: 497
I am sure it is WebEx after I experimented restart/kill the process of Webex.
edit: after ending the process in the task manager (open task manager, find webex and end process) ctrl+shift+m works again. (Windows 10)
Upvotes: 3
Reputation: 96
I had the same problem. I suppose it comes from WebEx as mentioned in the comments. I uninstalled WebEx but the problem remained. Then I cleaned Windows registry using the tool in CCleaner software and now the pipe shortcut is working again !
Upvotes: 2