ed: In-place editing of expressions

Description Usage Arguments Details See Also Examples

View source: R/ed.r

Description

Edit an object in-place using the built-in edit function. If the first argument to ed is an integer, it will attempt to edit the last n lines, excluding references to ed or lastn.

Usage

1
2
ed(obj = 1, tweak = NULL, verbose = FALSE, echo = getOption("ed.echo"),
  show.attributes = getOption("ed.show.attributes"), by = 0, to = NULL)

Arguments

obj

ANY. It will be modified in place, i.e., calling ed(obj) is equivalent to obj <- edit(obj). If an integer is passed, the last obj lines in the interactive console will be edited and executed. The default is 1.

tweak

multiple. See by and to parameters.

verbose

logical. If TRUE, a copy of the edited value will be printed as a message.

echo

logical. Whether or not to edit the history in-place as well so that it shows up in the interactive command line. The default is getOption("ed.echo").

show.attributes

logical. Whether or not to show attributes when editing. The attributes will simply be copied over on editing if this is FALSE. The default is getOption("ed.show.attributes")

by

numeric. If obj is an integer, it will skip this many lines (i.e., it allows editing & executing *past* blocks in the history)

to

character. If obj is a character, edit all expressions the history starting with the latest matching obj up to the next latest matching to.

Details

One can choose the editor by passing an editor argument. The default value for this is getOption("editor") as in the edit function; possible values are "vi", "emacs", "pico", "xemacs", "xedit", and potentially more (OS specific).

See Also

edit

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Not run: 
some_function <- function(x) { x + 1 }
ed(some_function) # opens an in-line editor to mess with some_function

x <- 1:5
ed(x) # Will edit x in-place

ed(2) # Will edit a file containing
      #   some_function <_ function(x) { x + 1 }
      #   x <- 1:5
      # Editing and leaving the file will trigger its execution

x <- 10; attr(x, "y") <- 5
ed(x, v = T, e = T, s = T) # Will print a message containing the modified change
  # as well as echoing the results to the history, and showing attributes
  # in the editing pane.

ed("1:5", to = "10") # Edit the last two lines -- they are found through regular expressions
ed("1:5", "10")      # This actually works too :)

## End(Not run)

robertzk/productivus documentation built on July 23, 2019, 2:22 p.m.