vi key bindings in R
I am working on learning R. For those that don’t know, R is a programming language and program a bit similar to Matlab, but is particularly designed for statistics. It is free and open source, and pretty fast and flexible. It has a pretty nice library interface, with lots of user contributed libraries at CRAN (The comprehensive R archive network — modeled after CTAN and CPAN (Tex and Perl respectively)).
On *nix systems, R uses the readline library to give a command history. So I can simply type the up arrow, and find the last command I used. I just discovered that it can also search the command history in the same way as in my BASH shell. Since I like vi, I use vi key bindings in bash. I was pleasantly surprised when R automatically used these as well. I am not sure if it gets them from my .bashrc file or my .inputrc file, since I have vi keymaps set in both.
set -o vi
set editing-mode vi
set keymap vi
So when I am using R, I can search the history for “foo” by typing:
and then use ‘n’ and ‘N’ to go to the next or previous match.