lifecycle::badge("experimental")
Splits the selection every n characters
and inserts it in a paste0()
call.
See `Details`
for how to set a key command.
wrapStringAddin(
selection = NULL,
indentation = 0,
every_n = NULL,
tolerance = 10,
insert = TRUE
)
Inserts the following (with newlines and correct indentation):
paste0("first n chars", "next n chars")
Returns NULL
invisibly.
String of code. (Character)
N.B. Mainly intended for testing the addin programmatically.
Indentation of the selection. (Numeric)
N.B. Mainly intended for testing the addin programmatically.
Number of characters per split.
If NULL
, the following is used to calculate the string width:
max(min(80 - indentation, 70), 50)
N.B. Strings shorter than every_n + tolerance
will not be wrapped.
Tolerance. Number of characters.
We may prefer not to split a string that's only a few
characters too long. Strings shorter than every_n + tolerance
will not be wrapped.
Whether to insert the wrapped text via
rstudioapi::insertText()
or return it. (Logical)
N.B. Mainly intended for testing the addin programmatically.
Ludvig Renbo Olsen, r-pkgs@ludvigolsen.dk
After installing the package. Go to:
Tools >> Addins >> Browse Addins >> Keyboard Shortcuts
.
Find "Wrap String with paste0"
and press its
field under Shortcut
.
Press desired key command, e.g. Alt+P
.
Press Apply
.
Press Execute
.
Other addins:
assertCollectionAddin()
,
dputSelectedAddin()
,
initializeGXSFunctionAddin()
,
initializeTestthatAddin()
,
insertExpectationsAddin()
,
navigateTestFileAddin()