Skip to contents

Pass a string to be executed as a Vim command in the RStudio source editor. This function then sends the input key presses to type out the command.

Usage

rsvim_exec(command, wait = 0)

Arguments

command

String. A Vim command to execute. This is the text you would type in the Vim command dialogue box after pressing : and before pressing Enter.

wait

Numeric. Seconds to delay between typing the command and pressing enter. This can give time to review commands for testing and troubleshooting.

Value

Returns NULL invisibly.

Conditions

Vim keybindings must be enabled and you must have a file open at the front in the source editor so that you could execute the commands if you moved focus to source yourself. It will error with a different at the front like a View() tab.

See also

rsvim_exec_file() to run all commands from a config file.

Examples

if (FALSE) { # \dontrun{
#' # Create a home-row binding jk to go from insert mode to normal mode.
rsvim_exec("imap jk <Esc>")

# Replace "text" with "rep" everywhere in the active document.
rsvim_exec("%s/text/rep/g")

# Bring up RStudio's Vim help (see Ex Commands for other commands)
rsvim_exec("help")
} # }