Learn R Programming

utils (version 3.6.2)

file.edit: Edit One or More Files

Description

Edit one or more files in a text editor.

Usage

file.edit(…, title = file, editor = getOption("editor"),
          fileEncoding = "")

Arguments

one or more character vectors containing the names of the files to be displayed. These will be tilde-expanded: see path.expand.

title

the title to use in the editor; defaults to the filename.

editor

the text editor to be used, usually as a character string naming (or giving the path to) the text editor you want to use See ‘Details’.

fileEncoding

the encoding to assume for the file: the default is to assume the native encoding. See the ‘Encoding’ section of the help for file.

Details

The behaviour of this function is very system-dependent. Currently files can be opened only one at a time on Unix; on Windows, the internal editor allows multiple files to be opened, but has a limit of 50 simultaneous edit windows.

The title argument is used for the window caption in Windows, and is currently ignored on other platforms.

Any error in re-encoding the files to the native encoding will cause the function to fail.

The default for editor is system-dependent. On Windows it defaults to "internal", the script editor, and in the macOS GUI the document editor is used whatever the value of editor. On Unix the default is set from the environment variables EDITOR or VISUAL if either is set, otherwise vi is used.

editor can also be an R function, in which case it is called with the arguments name, file, and title. Note that such a function will need to independently implement all desired functionality.

On Windows, UTF-8-encoded paths not valid in the current locale can be used.

See Also

files, file.show, edit, fix,

Examples

Run this code
# NOT RUN {
# open two R scripts for editing
file.edit("script1.R", "script2.R")
# }

Run the code above in your browser using DataLab