Title: | RStudio Add-ins to Format R Markdown files (RETIRED PACKAGE) |
---|---|
Description: | The development of `spAddins` ended in 2018 as the package retired in favor of packages `addins.rmd` and `addins.rs`. ... RStudio Add-ins to Format Text and Insert Operators ... A set of RStudio addins that are designed to be used in combination with user-defined RStudio keyboard shortcuts. These addins either: 1) insert text at a cursor position (e.g. insert operators %>%, <<-, %$%, etc.), 2) replace symbols in selected pieces of text (e.g., convert backslashes to forward slashes which results in stings like "c:\data\" converted into "c:/data/") or 3) enclose text with special symbols (e.g., converts "bold" into "**bold**") which is convenient for editing R Markdown files. |
Authors: | Vilmantas Gegzna [aut, cre, cph] |
Maintainer: | Vilmantas Gegzna <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.3 |
Built: | 2024-11-02 03:11:45 UTC |
Source: | https://github.com/gegznav/spaddins |
RStudio add-ins, which enclose selected text with symbols that have special interpretation in R Markdown. Function, symbols and interpretation
rmd_bold()
: between **
and **
as bold;
rmd_italics()
: between _
and _
as italics;
rmd_bold_italics()
: between **_
and _**
as bold italics;
rmd_bold2()
: between __
and __
as bold;
rmd_italics2()
: between *
and *
as italics;
rmd_code_inline()
: between back-ticks (“) as inline code;
rmd_r_code_inline()
: formats text as inline R code to evaluate;
rmd_superscript()
: between ^
and ^
as superscript;
rmd_subscript()
: between ~
and ~
as subscript;
rmd_strikethrough()
: between ~~
and ~~
as strike-through text.
rmd_a_bold() rmd_a_italics() rmd_a_bold_italics() rmd_a_bold2() rmd_a_italics2() rmd_code_inline() rmd_code_inline_r() rmd_code_inline_highlighted_as_r() rmd_a_superscript() rmd_a_subscript() rmd_a_strikethrough() rmd_horizontal_rule() rmd_link_url() rmd_insert_figure()
rmd_a_bold() rmd_a_italics() rmd_a_bold_italics() rmd_a_bold2() rmd_a_italics2() rmd_code_inline() rmd_code_inline_r() rmd_code_inline_highlighted_as_r() rmd_a_superscript() rmd_a_subscript() rmd_a_strikethrough() rmd_horizontal_rule() rmd_link_url() rmd_insert_figure()
Other R Markdown formatting add-ins: rmd_code_block
,
rmd_equations
, rmd_list
RStudio add-in to insert HTML elements
RStudio add-in to insert either ->
, ->>
,
<-
or <<-
at the cursor position.
html_insert_space() rs_insert_arrow_rl() rs_insert_arrow_rl2() rs_insert_arrow_lr() rs_insert_arrow_lr2()
html_insert_space() rs_insert_arrow_rl() rs_insert_arrow_rl2() rs_insert_arrow_lr() rs_insert_arrow_lr2()
use hotkeys combination ALT
+ -
to insert <-
in RStudio.
Assignment operators assignOps.
Other 'Insert at cursor position' addins: insert_symbol_sequences
Other 'Insert at cursor position' addins: insert_symbol_sequences
## Not run: \donttest{ library(spAddins) rs_insert_arrow_rl() ## <- rs_insert_arrow_rl2() ## <<- rs_insert_arrow_lr() ## -> rs_insert_arrow_lr2() ## ->> } ## End(Not run)
## Not run: \donttest{ library(spAddins) rs_insert_arrow_rl() ## <- rs_insert_arrow_rl2() ## <<- rs_insert_arrow_lr() ## -> rs_insert_arrow_lr2() ## ->> } ## End(Not run)
These add-ins insert operators %>%
, %<>%
, %$%
,
and %T>%
at the cursor position.
The operators are defined in package magrittr.
rs_insert_pipe() rs_insert_update_pipe() rs_insert_exposition_pipe() rs_insert_tee_pipe()
rs_insert_pipe() rs_insert_update_pipe() rs_insert_exposition_pipe() rs_insert_tee_pipe()
Operator does not work unless package magrittr or equivalent is loaded.
Other 'Insert at cursor position' add-ins: rs_insert_infix_R
,
rs_insert_infix_in
,
rs_insert_infix_not_in
,
rs_insert_matrix_multiplication
Use
rs_insert_ss_line()
to insert ------
;rs_insert_ds_line()
to insert ======
;rs_insert_dw_line()
to insert ~~~~~~
at the cursor position.
rs_insert_line_ss(start = rs_get_ind_first_selected_col(), end = 79) rs_insert_line_ds(start = rs_get_ind_first_selected_col(), end = 79) rs_insert_line_sw(start = rs_get_ind_first_selected_col(), end = 79)
rs_insert_line_ss(start = rs_get_ind_first_selected_col(), end = 79) rs_insert_line_ds(start = rs_get_ind_first_selected_col(), end = 79) rs_insert_line_sw(start = rs_get_ind_first_selected_col(), end = 79)
start |
(numeric) The number of column the line begins at. |
end |
(numeric) The number of column the line ends at. |
Other 'Insert at cursor position' addins: insert_arrows
Repeat sequence of symbols.
repeat_symbol(text, length.out)
repeat_symbol(text, length.out)
text |
(character) The symbol (or sequence of symbols) to be repeated until desired length of string. |
length.out |
(integer) The length of the sequence. |
Sting of defined length.
repeat_symbol(".", 10) repeat_symbol("..+", 10)
repeat_symbol(".", 10) repeat_symbol("..+", 10)
RStudio add-in to manage various types of slashes. Select a piece of text with a cursor and do the necessary replacement operation in the selected text:
rs_replace_slash_bs2d
single back-slash into double back-slash;
rs_replace_slash_bd2s
double back-slash into single back-slash;
rs_replace_slash_b2fw
back-slash into forward-slash;
rs_replace_slash_fw2b
forward-slash into back-slash.
rs_replace_slash_bs2d() rs_replace_slash_bd2s() rs_replace_slash_b2fw() rs_replace_slash_fw2b()
rs_replace_slash_bs2d() rs_replace_slash_bd2s() rs_replace_slash_b2fw() rs_replace_slash_fw2b()
RStudio add-in to insert selected lines into code block:
rmd_code_block()
- verbatim code block;
rmd_code_block_r()
- R code block.
.
rmd_code_block_r_split()
- splits block of R code.
These functions internally use function
rs_enclose_all_with_lines()
-
that adds lines above and below the selection.
rmd_code_block_r() rmd_code_block() rmd_code_block_r_split()
rmd_code_block_r() rmd_code_block() rmd_code_block_r_split()
Other R Markdown formatting add-ins: format_rmd
,
rmd_equations
, rmd_list
Select a piece of text with a cursor and call these functions as an add-in
to enclose the text with special symbols. Text between $.$
is
interpreted as an inline equation and between $$.$$
or \[.\]
as a block equation in R Markdown.
rmd_equation_inline() rmd_equation_block() rmd_equation_block2()
rmd_equation_inline() rmd_equation_block() rmd_equation_block2()
Other R Markdown formatting add-ins: format_rmd
,
rmd_code_block
, rmd_list
RStudio add-ins to format text as R Markdown headings.
rmd_b_heading_1() rmd_b_heading_2() rmd_b_heading_3() rmd_b_heading_4() rmd_b_heading_5() rmd_b_heading_6() rmd_b_heading_01a_title() rmd_b_heading_01b_subtitle()
rmd_b_heading_1() rmd_b_heading_2() rmd_b_heading_3() rmd_b_heading_4() rmd_b_heading_5() rmd_b_heading_6() rmd_b_heading_01a_title() rmd_b_heading_01b_subtitle()
RStudio add-ins which convert text into R Markdown lists. For the first-level lists:
rmd_list()
- the main function, that make lists;
rmd_unordered_list()
- unordered list;
rmd_numbered_list()
- numbered list;
rmd_lettered_list()
- lettered list (non-capital English letters);
rmd_master_list()
- master list (which numbering continues throughout the document).
rmd_list(type = "unordered", level = 1, context = get_context()) rmd_block_quotes() rmd_line_blocks() rmd_list_unordered() rmd_list_unordered_2() rmd_list_numbered() rmd_list_numbered_2() rmd_list_lettered() rmd_list_lettered_2() rmd_list_z_example_list()
rmd_list(type = "unordered", level = 1, context = get_context()) rmd_block_quotes() rmd_line_blocks() rmd_list_unordered() rmd_list_unordered_2() rmd_list_numbered() rmd_list_numbered_2() rmd_list_lettered() rmd_list_lettered_2() rmd_list_z_example_list()
type |
(character) the type of list "unordered", "numbered", "lettered", "LETTERED", "master". |
level |
(integer) the level of list. |
context |
Object with context of active R Studio document
(class |
Other R Markdown formatting add-ins: format_rmd
,
rmd_code_block
, rmd_equations
Insert examples of R Markdown tables.
rmd_table_1() rmd_table_2() rmd_table_3() rmd_table_4() rmd_table_5()
rmd_table_1() rmd_table_2() rmd_table_3() rmd_table_4() rmd_table_5()
Enclose selected rows with lines above and below:
rs_enclose_all_with_lines()
- all selected rows;
rs_enclose_first_row_with_lines()
- the first selected row only.
rs_enclose_all_with_lines(above = NA, below = NA, ensure_blank_above = FALSE, context = get_context()) rs_enclose_first_row_with_lines(above = NULL, below = NULL, ensure_blank_above = FALSE, context = get_context())
rs_enclose_all_with_lines(above = NA, below = NA, ensure_blank_above = FALSE, context = get_context()) rs_enclose_first_row_with_lines(above = NULL, below = NULL, ensure_blank_above = FALSE, context = get_context())
above |
(character) Text to be inserted in the row above the selection. |
below |
(character) Text to be inserted in the row below the selection (or the first row). |
ensure_blank_above |
(logical)
If |
context |
Object with context of active R Studio document
(class |
Enclose selection of text with certain symbols which usually have special meaning in R Markdown files.
rs_enclose_selection_with(symbol = "", symbol_before = symbol, symbol_after = symbol, context = get_context())
rs_enclose_selection_with(symbol = "", symbol_before = symbol, symbol_after = symbol, context = get_context())
symbol |
(character) A sequence of symbols to add on both sides of selection. |
symbol_before |
(character) A sequence of symbols to before the selection
(overrides value of |
symbol_after |
(character) A sequence of symbols to add after the selection
(overrides value of |
context |
Object with context of active R Studio document
(class |
If text is selected, the cursor is placed after the modified selection. If no text is selected, the cursor is placed between the inserted symbols.
Get index of the first/last row/column in the selection.
rs_get_ind_first_selected_col(context = get_context()) rs_get_ind_last_selected_col(context = get_context()) rs_get_ind_first_selected_row(context = get_context()) rs_get_ind_last_selected_row(context = get_context())
rs_get_ind_first_selected_col(context = get_context()) rs_get_ind_last_selected_col(context = get_context()) rs_get_ind_first_selected_row(context = get_context()) rs_get_ind_last_selected_row(context = get_context())
context |
Object with context of active R Studio document
(class |
Insert text at the beginning of the row.
rs_insert_at_row_start(row, text = NULL, id = NULL)
rs_insert_at_row_start(row, text = NULL, id = NULL)
row |
(integer) The index of the row. |
text |
(character) The text to add. |
id |
The document id. When |
Insert text at the beginning of the first selected row.
rs_insert_before_first_selected_row(text = "", ensure_blank_above = FALSE, context = get_context())
rs_insert_before_first_selected_row(text = "", ensure_blank_above = FALSE, context = get_context())
text |
(character) The text to add. |
ensure_blank_above |
(logical)
If |
context |
Object with context of active R Studio document
(class |
Call this function as an add-in to insert %in%
at the cursor position.
rs_insert_infix_in()
rs_insert_infix_in()
Operator %in%.
Other 'Insert at cursor position' add-ins: insert_magrittr_operators
,
rs_insert_infix_R
,
rs_insert_infix_not_in
,
rs_insert_matrix_multiplication
Call this function as an add-in to insert %!in%
at the cursor position.
rs_insert_infix_not_in()
rs_insert_infix_not_in()
Operator does not work unless a package which contains this operator is loaded.
Operator %in%.
Other 'Insert at cursor position' add-ins: insert_magrittr_operators
,
rs_insert_infix_R
,
rs_insert_infix_in
,
rs_insert_matrix_multiplication
Call this function as an add-in to insert %R%
at the cursor position.
rs_insert_infix_R()
rs_insert_infix_R()
Operator does not work unless library which contains this operator is loaded.
Operator %R% in rebus.
Other 'Insert at cursor position' add-ins: insert_magrittr_operators
,
rs_insert_infix_in
,
rs_insert_infix_not_in
,
rs_insert_matrix_multiplication
Call this function as an add-in to insert %*%
at the cursor position.
rs_insert_matrix_multiplication()
rs_insert_matrix_multiplication()
Operator %*% for matrix multiplication.
Other 'Insert at cursor position' add-ins: insert_magrittr_operators
,
rs_insert_infix_R
,
rs_insert_infix_in
,
rs_insert_infix_not_in
Insert a sequence of symbols.
rs_insert_symbol_seq(symbol, start_column = 1, end_column = 80)
rs_insert_symbol_seq(symbol, start_column = 1, end_column = 80)
symbol |
(character) A sequence of symbols to be repeated |
start_column |
(integer) Column position where the sequence begins. |
end_column |
(integer) Column position where the sequence stops. |
Replace text in selection.
rs_replace_in_selection(pattern, replacement, context = get_context())
rs_replace_in_selection(pattern, replacement, context = get_context())
pattern |
(character) A fixed pattern of text to be replaced (not a regular expression). |
replacement |
(character) The replacement text. |
context |
Object with context of active R Studio document
(class |
spAddins
provides a set of RStudio add-ins that
are designed to be used in combination with user-defined RStudio keyboard
shortcuts. These add-ins either insert text at the cursor position (e.g. insert
operators %>%
, <<-
, %$%
, etc.), replace symbols
in selected pieces of text, e.g., convert back-slashes to forward-slashes or
enclose text with special symbols (e.g., converts "bold" into "**bold**")
which is convenient for editing R Markdown files.
License:
MIT URL:
https://github.com/GegznaV/spAddins Bug reports and suggestions:
https://github.com/GegznaV/spAddins/issues Author:
Vilmantas Gegzna
Use the links below to learn more about RStudio add-ins and especially how to use them in combination with user-defined keyboard shortcuts: