Relief from backslash irritation in R for Windows

前端 未结 9 2311
没有蜡笔的小新
没有蜡笔的小新 2021-02-10 10:41

Early in my R life I discovered the pain of R and windows being on different pages when it came to the separator between directories and subdirectories. Eventhough I know about

9条回答
  •  隐瞒了意图╮
    2021-02-10 11:14

    I've adapted the following autohotkey code shared to replace all backslashes with forward slashes whenever I paste anything in RStudio. There are pros and cons to this approach.

    Pros: You don't have to think about it. The code will only run if the active window is RStudio.

    Cons: The code is called every time you paste something in R. Each time it attempts to find backslashes and replace them with forward slashes.

    GroupAdd, R, RStudio
    
    ;replaces backslashes with forward slashes in a file name that is stored on the clipboard
    #IfWinActive ahk_group R
       ^v::
          StringReplace,clipboard,clipboard,\,/,All
          send %clipboard%
       return
    #IfWinActive
    

提交回复
热议问题