How to install command-line editor in Splus?

R has a command-line editor which allows us to retrieve and edit commands we entered before. We also can install a command-line editor in Splus.

STEP 1

If you use Bourne, Korn, Bash or Z-Shell, type the following lines into your .bashrc file which is in your home directory:

    export EDITOR="/usr/local/bin/vim"
    export S_CLEDITOR="/usr/local/bin/vim"
    export VISUAL="/usr/local/bin/vim"

If you use C-Shell or TC-Shell, then type the following lines into your .cshrc file which is in your home directory:

    setenv EDITOR "/usr/local/bin/vim"
    setenv S_CLEDITOR "/usr/local/bin/vim"
    setenv VISUAL "/usr/local/bin/vim"

If you want to use emacs instead of vi, then simply replace the vim with emacs.

 

STEP 2

in your home directory, type command

    source .bashrc

or

    source .cshrc

 

STEP 3

type

    Splus -e

to invoke editor when you enter into Splus session.

The most useful editing commands are summarized in the following table:

COMMAND                 emacs           vi

backward character      Ctrl-B          Esc, h
forward character       Ctrl-F          Esc, l
previous line           Ctrl-P          Esc, k
next line               Ctrl-N          Esc, j
beginning of line       Ctrl-A          Esc, ^ (Shift-6)
end of line             Ctrl-E          Esc, $ (Shift-4)
forward word            Esc, f          Esc, w
backward word           Esc, b          Esc, b

kill char               Ctrl-D          Esc, x
kill line               Ctrl-K          Esc, Shift-d
delete word             Esc, d          Esc, dw

search backward         Ctrl-R          Esc, ?   
yank                    Ctrl-Y          Esc, Shift-y
transpose chars         Ctrl-T          Esc, xp

You can type Splus command

?Command.edit

to get the above table.

FAQ Category