Skip to main content

Action

Enum Action 

Source
pub enum Action {
Show 30 variants Move(Motion), Operator(Operator), ApplyOperator { op: Operator, motion: Motion, }, Edit(Edit), ChangeMode(Mode), Command { name: String, args: Vec<String>, }, InsertChar(char), SubmitCommand, Undo, Redo, Save, Quit, SearchOpen(Direction), SearchRepeat { reverse: bool, }, SearchWord { reverse: bool, }, ClearSearchHighlight, SearchSubmitOperated { op: Operator, }, TextObject(TextObject), ApplyOperatorObject { op: Operator, object: TextObject, }, RepeatLastChange, JumpBack, JumpForward, PromptBackspace, PromptCaret { to: CaretMove, }, SearchPreviewStep { forward: bool, }, PromptDelete, PromptDeleteWord, PromptClearToStart, PromptHistory { back: bool, }, Pending,
}
Expand description

A fully-resolved editor action — what the keymap emits, what the buffer consumes.

Variants§

§

Move(Motion)

Move every cursor by motion.

§

Operator(Operator)

Begin an operator (the d/c/y key). The editor enters operator-pending: the next motion composes into an Action::ApplyOperator. Resolved by the operator-pending FSM, never executed directly.

§

ApplyOperator

Apply a pending operator over a motion (delete-word, yank-line, etc.).

Fields

§motion: Motion
§

Edit(Edit)

Apply a primitive edit at each cursor.

§

ChangeMode(Mode)

Enter the given mode.

§

Command

Run a named command (via the command registry).

Fields

§name: String
§args: Vec<String>
§

InsertChar(char)

Insert a character at each caret. Separate from Edit so the keymap can stay ignorant of rope details.

§

SubmitCommand

Submit a minibuffer / command-mode line (e.g. :w, :q).

§

Undo

Undo / redo one change.

§

Redo

§

Save

Save the current buffer.

§

Quit

Quit the editor.

§

SearchOpen(Direction)

Open the search prompt in direction (the / and ? keys).

The prompt reuses Mode::Command rather than adding a mode variant: vim’s / IS the command-line with a different prompt character, and this module’s own doc states new modes are layered through pending state, not new variants. SearchState’s typed Option<Prompt> is what disambiguates a <CR> that submits a search from one that submits an ex-command — a discriminator that cannot be forgotten, unlike a bool.

§

SearchRepeat

n (reverse = false) / N (reverse = true) — jump to the next match, relative to the direction the search was committed with, so N after a ? search moves forward.

Fields

§reverse: bool
§

SearchWord

* (reverse = false) / # (reverse = true) — search the whole word under the cursor. Literal, not regex: the word may contain . or [ and the user means those characters.

Fields

§reverse: bool
§

ClearSearchHighlight

:noh — stop highlighting matches while keeping the pattern, so n still works. Distinct from cancelling a search.

§

SearchSubmitOperated

d/foo<CR> — commit the open search prompt and apply op from the prompt’s ORIGIN to wherever the search lands.

Emitted only by the operator-pending machine; no keymap produces it. It exists because committing a search MOVES the cursor, and the operator needs the pre-move position as its start point. Carrying the operator through the commit makes “operate over a search” one atomic action instead of two steps racing to own the cursor.

Fields

§

TextObject(TextObject)

gn / gN — the next/previous match AS AN OBJECT.

Not a motion. A motion resolves to a POINT and an operator acts over [cursor, point); gn names an EXTENT that need not start at the cursor, so dgn deletes the whole match wherever it is. That distinction is why this is its own action rather than a Motion variant — folding it into Motion would silently give [cursor, match.start), which deletes the text BEFORE the match.

§

ApplyOperatorObject

{operator}gn — apply op over a text object’s extent.

Emitted only by the operator-pending machine.

Fields

§object: TextObject
§

RepeatLastChange

. — repeat the last text change.

Vim’s most-used key, and the half that makes cgn a workflow rather than a curiosity: cgn changes the next match, then . changes the one after it, giving a per-instance confirmable rename with no multi-cursor machinery.

§

JumpBack

<C-o> — walk back to where the last far jump was taken from.

Lives beside the search actions because search is what made it necessary — committing a / used to be a one-way door — but it is not a search action: G, gg, % and tag jumps are the other consumers.

§

JumpForward

<C-i> — walk forward again after Action::JumpBack.

§

PromptBackspace

Backspace inside a command-line or search prompt.

Key::Backspace was previously bound in NO mode, so the minibuffer could be typed into but never corrected — a typo meant Esc and start again. One action serves both prompts; the runtime routes it by whether a search prompt is open.

§

PromptCaret

Move the caret inside an open prompt ( Home End).

The prompt was append-only until this existed, so a typo in the middle of a pattern could only be fixed by deleting back to it.

Fields

§

SearchPreviewStep

<C-g> / <C-t> — step the search PREVIEW to the next/previous match without committing.

Distinct from n in the one way that matters: this is still cancellable. Escape returns to where the search started, which n after a commit cannot do.

Fields

§forward: bool
§

PromptDelete

<Del> — delete the character AT the prompt caret.

§

PromptDeleteWord

<C-w> — delete the word before the prompt caret.

§

PromptClearToStart

<C-u> — delete from the prompt caret back to the start.

§

PromptHistory

Up/Down inside a prompt — walk search history.

back = true is older. Stepping forward past the newest entry restores the text that was being typed when browsing began, so arrowing through history and back never destroys a half-typed pattern.

Fields

§back: bool
§

Pending

No-op — used when a key sequence is pending but not yet complete.

Implementations§

Source§

impl Action

Source

pub const fn text_effect(&self) -> TextEffect

Classify this action’s effect on buffer text.

Total over Action — no wildcard arm. A new variant fails to compile here rather than silently defaulting to “preserves”, which is the direction that produces a stale-cache bug rather than a slow one.

Deliberately CONSERVATIVE where a variant’s reach is open-ended: Command/SubmitCommand can run an ex-command that edits, and the keymap’s PromptBackspace doubles as the buffer Backspace outside a prompt. Over-reporting costs one extra scan; under-reporting paints the wrong columns, so the asymmetry decides the doubtful cases.

Source§

impl Action

Source

pub const fn highlight_effect(&self) -> HighlightEffect

Classify this action’s effect on search highlighting.

Total over Action — no wildcard arm. “We forgot to clear on the new command” becomes unconstructible rather than remembered: adding a variant forces the decision here.

Trait Implementations§

Source§

impl Clone for Action

Source§

fn clone(&self) -> Action

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Action

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Action

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Action

Source§

impl JsonSchema for Action

Source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for Action

Source§

fn eq(&self, other: &Action) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Action

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Action

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.