Preliminaries
When the GNU readline library is available at the time R is configured for compilation under UNIX, an inbuilt command line editor allowing recall, editing and re-submission of prior commands is used. Note: this appendix does not apply to the GNOME interface under UNIX, only to the standard command-line interface. It can be disabled (useful for usage with ESS) using the startup option ‘--no-readline’. Windows versions of R have somewhat simpler command-line editing: see ‘Console’ under the ‘Help’ menu of the GUI, and the file ‘README.Rterm’ for command-line editing under Rterm.exe. When using R with readline capabilities, the functions described below are available. Many of these use either Control or Meta characters. Control characters, such as Control-m, are obtained by holding the (CTRL) down while you press the hmi key, and are written as C-m below. Meta characters, such as Meta-b, are typed by holding down (META) and pressing (b), and written as M-b in the following. If your terminal does not have a (META) key, you can still type Meta characters using two-character sequences starting with ESC. Thus, to enter M-b, you could type (ESC)(b). The ESC character sequences are also allowed on terminals with real Meta keys. Note that case is significant for Meta characters.
Editing actions
The R program keeps a history of the command lines you type, including the erroneous lines, and commands in your history may be recalled, changed if necessary, and re-submitted as new commands. In Emacs-style command-line editing any straight typing you do while in this editing phase causes the characters to be inserted in the command you are editing, displacing any characters to the right of the cursor. In vi mode character insertion mode is started by M-i or M-a, characters are typed and insertion mode is finished by typing a further (ESC). Pressing the (RET) command at any time causes the command to be re-submitted. Other editing actions are summarized in the following table.
Command-line editor summary
Command recall and vertical motion
C-p Go to the previous command (backwards in the history).
C-n Go to the next command (forwards in the history).
C-r text Find the last command with the text string in it.
On most terminals, you can also use the up and down arrow keys instead of C-p and C-n, respectively.
Horizontal motion of the cursor
C-a Go to the beginning of the command.
C-e Go to the end of the line.
M-b Go back one word.
M-f Go forward one word.
C-b Go back one character.
C-f Go forward one character.
On most terminals, you can also use the left and right arrow keys instead of C-b and C-f, respectively.
Editing and re-submission
text Insert text at the cursor.
C-f text Append text after the cursor.
(DEL) Delete the previous character (left of the cursor).
C-d Delete the character under the cursor.
M-d Delete the rest of the word under the cursor, and “save” it.
C-k Delete from cursor to end of command, and “save” it.
C-y Insert (yank) the last “saved” text here.
C-t Transpose the character under the cursor with the next.
M-l Change the rest of the word to lower case.
M-c Change the rest of the word to upper case.
(RET) Re-submit the command to R.
The final (RET) terminates the command line editing sequence.
Next: References
Summary: Index