Trouble using the back arrow key in R

Trouble using the back arrow key in R

I am sshing to a linux server via ExtraPutty and am running R. If I type some code and then I hit the back arrow three times, I get the following output:

blah blah some code^[[D^[[D^[[D

The R console won't allow me to go backwards on a line. My arrow keys work fine when I exit R and just use C shell normally. Any ideas why this might be happening? Is it a key event forwarding issue?

答案1

Create a file (or add to it if it exists) called .inpurc in your home directory on the remote system and add these lines to it:

"\e[1;5D": backward-word
"\eOd": backward-word

"\e[1;5C": forward-word
"\eOc": forward-word

My guess (and it's just a guess) is that for some reason R is not reading the system wide /etc/inputrc file which is where that kind of keyboard shortcut is stored. Creating your own local copy with the needed assignments might solve it.

相关内容