pub enum SelectionEdit {
Show 59 variants
InsertText(String),
DeleteBack,
DeleteForward,
InsertNewlineAbove,
InsertNewlineBelow,
InsertNewlineSmart,
ToggleBulletAtLineStart,
ToggleBulletWithContinuationIndent {
unit: IndentUnit,
},
DeleteWordBackward,
DeleteWordForward,
DeleteToLineStart,
DeleteToLineEnd,
DeleteToBracket,
DuplicateLine,
DuplicateSelection,
MoveLineUp,
MoveLineDown,
JoinLines,
JoinSelectedLines,
SortLines(SortKind),
ReverseLines,
UniqueLines,
ShuffleLines(u64),
TrimTrailingWhitespace,
TrimTrailingWhitespaceAll,
TrimWhitespaceAll,
WrapAtColumn(u32),
ReflowParagraph(u32),
TransposeChars,
TransposeWords,
ChangeCase(CaseKind),
Indent {
unit: IndentUnit,
},
Outdent {
unit: IndentUnit,
},
SpacesToTabs {
tab_width: u32,
},
TabsToSpaces {
tab_width: u32,
},
ConvertLineEndings(LineEnding),
ConvertLineEndingsAll(LineEnding),
TabsToSpacesAll {
tab_width: u32,
},
SurroundSelection {
open: String,
close: String,
},
MarkdownToggleEmphasis(EmphasisKind),
MarkdownSetHeading(u8),
MarkdownCycleHeading(i32),
MarkdownPromoteSection,
MarkdownDemoteSection,
MarkdownMoveSectionUp,
MarkdownMoveSectionDown,
MarkdownToggleBullet,
MarkdownToggleNumbered,
MarkdownToggleCheckbox,
MarkdownToggleTask,
MarkdownCycleListMarker,
MarkdownRenumberList,
MarkdownWrapInBlockquote,
MarkdownInsertCodeFence,
MarkdownInsertLink,
MarkdownInsertImageRef,
MarkdownStripFormatting,
InsertPair {
open: String,
close: String,
},
DeletePair {
open: char,
close: char,
},
}Expand description
A selection-aware edit requested by an editor command.
New variants land here as commands graduate from “named in spec” to “implemented”. Each variant maps to exactly one undo group.
Variants§
InsertText(String)
Insert or replace each active selection with the supplied text.
DeleteBack
Delete the selected text, or one character before each caret.
DeleteForward
Delete the selected text, or one character after each caret.
InsertNewlineAbove
Insert a newline on a fresh line above each selection’s line, with the caret landing on the new line.
InsertNewlineBelow
Insert a newline on a fresh line below each selection’s line, caret at the new line.
InsertNewlineSmart
Insert a newline that inherits the leading indentation of the caret’s current line.
ToggleBulletAtLineStart
Toggle a - bullet marker right after each selection line’s
leading whitespace. Adding the marker shifts the caret’s byte
column by +2 so the cursor stays on the same content character
(visually unchanged). Removing it shifts by -2 (clamped to the
leading-whitespace column). Plain-text variant of
SelectionEdit::MarkdownToggleBullet — it doesn’t depend on
markdown parse state and is meant for the Ctrl+R quick-toggle
shortcut.
ToggleBulletWithContinuationIndent
Like SelectionEdit::ToggleBulletAtLineStart, but for a multi-line
selection the add path also prepends one indent unit to every covered
line after the first (turning the selection into a bulleted list whose
continuation lines are indented under the first item); the strip path
removes both the bullet and that indent. A single-line selection
behaves identically to the plain toggle. Bound to Ctrl+Shift+R.
Fields
unit: IndentUnitIndent unit (tab or N spaces) prepended to continuation lines,
read live from the dispatch context (mirrors editor.indent).
DeleteWordBackward
Delete text from the caret backward to the previous word boundary.
DeleteWordForward
Delete text from the caret forward to the next word boundary.
DeleteToLineStart
Delete from the caret back to the start of the line (or first non-whitespace if already at line start).
DeleteToLineEnd
Delete from the caret forward to the end of the line.
DeleteToBracket
Delete from the caret to the matching bracket, if any.
DuplicateLine
Duplicate the entire line(s) covered by each selection.
DuplicateSelection
Duplicate the bytes spanned by each selection (caret selections duplicate nothing).
MoveLineUp
Move each selected line up one position.
MoveLineDown
Move each selected line down one position.
JoinLines
Join the line below each selection’s line into the current line.
JoinSelectedLines
Collapse every line break within the lines covered by each selection
into a single space, joining the whole selected block into one line
(VS Code “Join Lines”). Distinct from SelectionEdit::JoinLines,
which only folds the single line below each caret (Vim J).
SortLines(SortKind)
Sort the lines covered by selections.
ReverseLines
Reverse the order of lines covered by selections.
UniqueLines
Drop duplicate lines covered by selections (case-sensitive, stable).
ShuffleLines(u64)
Pseudo-randomly reorder the lines covered by selections, seeded for determinism (the seed is hashed into the LCG).
TrimTrailingWhitespace
Trim trailing whitespace from every line covered by selections.
TrimTrailingWhitespaceAll
Phase B14: trim trailing whitespace on every line in the buffer
regardless of selection. Used by the explicit
editor.trim_trailing_whitespace command and the on-save hook.
TrimWhitespaceAll
Strip leading and trailing whitespace from every line in the
buffer (one undo group). Used by the explicit editor.trim_whitespace
command. Per-line leading strip removes indentation by design — the
literal “trim each line” reading, distinct from
SelectionEdit::TrimTrailingWhitespaceAll.
WrapAtColumn(u32)
Hard-wrap each paragraph covered by selections at column columns.
ReflowParagraph(u32)
Reflow each paragraph at column columns, preserving leading
whitespace.
TransposeChars
Transpose the two characters straddling each caret.
TransposeWords
Transpose the two words straddling each caret.
ChangeCase(CaseKind)
Change case of the bytes inside each selection (or the word at each caret).
Indent
Indent each selected line by one indent unit.
Fields
unit: IndentUnitIndent unit (tab or N spaces).
Outdent
Outdent each selected line by one indent unit.
Fields
unit: IndentUnitIndent unit (tab or N spaces).
SpacesToTabs
Replace runs of tab_width spaces with tabs.
TabsToSpaces
Replace tabs with tab_width spaces.
ConvertLineEndings(LineEnding)
Convert line endings of every covered line.
ConvertLineEndingsAll(LineEnding)
Phase C2 — convert line endings on every line in the buffer regardless of selection. Used by the status-bar click handler and the C3 mixed-LE normalize chip.
TabsToSpacesAll
Phase C3 — replace every tab in the buffer with tab_width
spaces, regardless of selection. Used by the mixed-indent
normalize chip.
SurroundSelection
Wrap each non-empty selection in open … close.
Fields
MarkdownToggleEmphasis(EmphasisKind)
Toggle markdown emphasis around each selection.
MarkdownSetHeading(u8)
Set the heading level of each covered line. level == 0 strips the
heading; 1..=6 rewrites the prefix.
MarkdownCycleHeading(i32)
Cycle the heading level on each covered line (+1/-1).
MarkdownPromoteSection
Promote (decrease level) the section enclosing each caret.
MarkdownDemoteSection
Demote (increase level) the section enclosing each caret.
MarkdownMoveSectionUp
Move the section enclosing each caret upward past the previous sibling section.
MarkdownMoveSectionDown
Move the section enclosing each caret downward past the next sibling section.
MarkdownToggleBullet
Toggle a - bullet prefix on each covered line. Shares the
content-relative planner with SelectionEdit::ToggleBulletAtLineStart
(plan_toggle_bullet_at_line_start), so the caret stays on the same
content character across add/remove and an ordered→bullet conversion.
MarkdownToggleNumbered
Toggle a 1. numbered prefix on each covered line.
MarkdownToggleCheckbox
Toggle a [ ]/[x] checkbox prefix on each covered line.
MarkdownToggleTask
Toggle a - [ ] task-bullet prefix on each covered line: plain
or bulleted lines gain the task marker; existing task lines drop
it. Bound to Ctrl+E.
MarkdownCycleListMarker
Cycle the list marker between -, *, +.
MarkdownRenumberList
Phase B11: renumber the ordered list containing the caret.
MarkdownWrapInBlockquote
Prefix > on each covered line.
MarkdownInsertCodeFence
Wrap selections in fenced code blocks (or insert an empty fence).
MarkdownInsertLink
Wrap each non-empty selection as [text](url) with placeholder url.
MarkdownInsertImageRef
Insert  at each caret.
MarkdownStripFormatting
Strip markdown formatting from every covered line: heading
hashes, list/checkbox markers, blockquote prefixes, emphasis /
code / strikethrough delimiters, and link syntax (keeping the
link text). Conservative on intraword _ / lone * so code
identifiers and arithmetic survive.
InsertPair
Phase-16.5 auto-pair insert: at each caret, insert open
immediately followed by close, leaving the caret between
them. Lands as one undo group. Selections that already cover a
non-empty range fall back to surrounding the range with
open … close (so highlight + ( keeps the surround
behavior of Self::SurroundSelection).
DeletePair
Phase-16.5 backspace-aware delete-pair: at each caret, if the
preceding byte is open and the following byte is close,
delete both as one undo group. Otherwise the planner returns
Ok(None) so the caller can fall through to a normal
Self::DeleteBack.