vi(data=<<see below>>, file=<<see below>>, editor=sys.call()[1])
You can create your own function that uses an editor of your choice by assigning the vi function to an object with the same name as your editor; see the emacs example below.
Usually functions are edited, but data may be edited also.
MOTION. The cursor keys move a line up or down, or a character left or right at a time. The h, j, k and l keys perform these tasks even if the cursor keys are not set up properly on your keyboard.
w move forward a word. b move back a word. /xxx search for xxx. (n finds next occurrence.) control-d move down half a screen. control-u move up half a screen. control-f move down a screen. control-b move up a screen. shift-G go to the end of the file. :n go to line n.
INSERTION. o open a line below and start insertion. O open a line above and start insertion. i start insertion before the character that the cursor is on. a start insertion after the character that the cursor is on.
DELETION. dd delete the line that the cursor is on. dw delete to the end of the word that the cursor is on.
SAVE AND EXIT. :w to save changes. :q to exit; these may be combined into :wq.
This is a very minimal set of commands for vi, there are many more that can speed your editing greatly. See the references or other sources for more information.
Morgan, R. and McGilton, H. (1987). Introducing UNIX System V. McGraw-Hill, New York.
ttt <- vi(ttt) ttt <- vi( ) # re-edit after a syntax error vi(ttt) # forgot to make the assignment ttt <- .Last.value # assign edited version emacs <- vi emacs(mean) # uses emacs editor amp;# you can save empty.fun as a blank when creating a new function: empty.fun <- function() {} new.fun <- vi(empty.fun) amp;# or create a new editing function: my.vi <- function(name=NULL) { if (missing(name)) vi( ) else { name <- as.character(substitute(name)) if (!exists(name)) assign(name, function() {}) vi(get(name)) } } my.vi(foo) # works even when foo is non-existent.