| showEditSuggestion | R Documentation |
Displays an edit suggestion for a specified range in the active document. The suggestion shows what text would replace the given range. RStudio computes and displays the necessary insertions and deletions.
showEditSuggestion(range, text, id = NULL)
range |
A document range (or object coercible to a range) indicating
where the suggestion applies. Can be a |
text |
Character string containing the suggested replacement text for the specified range. |
id |
The document id. When |
The edit suggestion appears in the RStudio editor, showing what would change if the suggestion were accepted. Users can accept or dismiss the suggestion through RStudio's UI.
The range parameter specifies the region of text that would be replaced.
RStudio automatically computes the minimal diff between the current text in
that range and the suggested text.
Invisibly returns TRUE if the suggestion was successfully shown,
FALSE otherwise.
The showEditSuggestion function was added in version 2026.01.0
of RStudio.
setGhostText for inline completion suggestions,
insertText for direct text insertion,
modifyRange for programmatic range modification.
## Not run:
# Suggest replacing a word
range <- document_range(c(5, 1), c(5, 10))
showEditSuggestion(range, "corrected_text")
# Using vector notation
showEditSuggestion(c(5, 1, 5, 10), "corrected_text")
# Suggest for current selection
context <- getActiveDocumentContext()
selection <- primary_selection(context)
showEditSuggestion(selection$range, "improved code")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.