Skip to main content

VimState

Struct VimState 

Source
pub struct VimState {
Show 39 fields pub mode: Mode, pub pending: Pending, pub count: usize, pub last_find: Option<(char, bool, bool)>, pub last_change: Option<LastChange>, pub insert_session: Option<InsertSession>, pub visual_anchor: (usize, usize), pub visual_line_anchor: usize, pub block_anchor: (usize, usize), pub block_vcol: usize, pub yank_linewise: bool, pub pending_register: Option<char>, pub recording_macro: Option<char>, pub recording_keys: Vec<Input>, pub replaying_macro: bool, pub last_macro: Option<char>, pub last_edit_pos: Option<(usize, usize)>, pub last_insert_pos: Option<(usize, usize)>, pub change_list: Vec<(usize, usize)>, pub change_list_cursor: Option<usize>, pub last_visual: Option<LastVisual>, pub viewport_pinned: bool, pub replaying: bool, pub one_shot_normal: bool, pub search_prompt: Option<SearchPrompt>, pub last_search: Option<String>, pub last_search_forward: bool, pub jump_back: Vec<(usize, usize)>, pub jump_fwd: Vec<(usize, usize)>, pub insert_pending_register: bool, pub change_mark_start: Option<(usize, usize)>, pub search_history: Vec<String>, pub search_history_cursor: Option<usize>, pub last_input_at: Option<Instant>, pub last_input_host_at: Option<Duration>, pub last_substitute: Option<SubstituteCmd>, pub pending_closes: Vec<(usize, usize, char)>, pub last_sneak: Option<((char, char), bool)>, pub last_horizontal_motion: LastHorizontalMotion, /* private fields */
}

Fields§

§mode: Mode

Internal FSM mode. Kept in sync with current_mode after every step. Phase 6.6b: promoted from private to pub so the FSM body (moving to hjkl-vim in 6.6c–6.6g) can read/write it directly until the migration is complete.

§pending: Pending

Two-key chord in progress. Pending::None when idle.

§count: usize

Digit prefix accumulated before an operator or motion. 0 means no prefix was typed (treated as 1 by most commands).

§last_find: Option<(char, bool, bool)>

Last f/F/t/T target, for ; / , repeat.

§last_change: Option<LastChange>

Most-recent mutating command for . dot-repeat.

§insert_session: Option<InsertSession>

Captured on insert-mode entry: count, buffer snapshot, entry kind.

§visual_anchor: (usize, usize)

(row, col) anchor for char-wise Visual mode. Set on entry, used to compute the highlight range and the operator range without relying on tui-textarea’s live selection.

§visual_line_anchor: usize

Row anchor for VisualLine mode.

§block_anchor: (usize, usize)

(row, col) anchor for VisualBlock mode. The live cursor is the opposite corner.

§block_vcol: usize

Intended “virtual” column for the block’s active corner. j/k clamp cursor.col to shorter rows, which would collapse the block across ragged content — so we remember the desired column separately and use it for block bounds / insert-column computations. Updated by h/l only.

§yank_linewise: bool

Track whether the last yank/cut was linewise (drives p/P layout).

§pending_register: Option<char>

Active register selector — set by "reg prefix, consumed by the next y / d / c / p. None falls back to the unnamed ".

§recording_macro: Option<char>

Recording target — set by q{reg}, cleared by a bare q. While Some, every consumed Input is appended to recording_keys.

§recording_keys: Vec<Input>

Keys recorded into the in-progress macro. On q finish, these are encoded via [crate::input::encode_macro] and written to the matching named register slot, so macros and yanks share a single store.

§replaying_macro: bool

Set during @reg replay so the recorder doesn’t capture the replayed keystrokes a second time.

§last_macro: Option<char>

Last register played via @reg. @@ re-plays this one.

§last_edit_pos: Option<(usize, usize)>

Position of the most recent buffer mutation. Surfaced via the '. / `. marks for quick “back to last edit”.

§last_insert_pos: Option<(usize, usize)>

Position where the cursor was when insert mode last exited (Esc). Used by gi to return to the exact (row, col) where the user last typed, matching vim’s :h gi.

§change_list: Vec<(usize, usize)>

Bounded ring of recent edit positions (newest at the back). g; walks toward older entries, g, toward newer ones. Capped at [CHANGE_LIST_MAX].

§change_list_cursor: Option<usize>

Index into change_list while walking. None outside a walk — any new edit clears it (and trims forward entries past it).

§last_visual: Option<LastVisual>

Snapshot of the last visual selection for gv re-entry. Stored on every Visual / VisualLine / VisualBlock exit.

§viewport_pinned: bool

zz / zt / zb set this so the end-of-step scrolloff pass doesn’t override the user’s explicit viewport pinning. Cleared every step.

§replaying: bool

Set while replaying . / last-change so we don’t re-record it.

§one_shot_normal: bool

Entered Normal from Insert via Ctrl-o; after the next complete normal-mode command we return to Insert.

§search_prompt: Option<SearchPrompt>

Live / or ? prompt. None outside search-prompt mode.

§last_search: Option<String>

Most recent committed search pattern. Surfaced to host apps via Editor::last_search so their status line can render a hint and so n / N have something to repeat.

§last_search_forward: bool

Direction of the last committed search. n repeats this; N inverts it. Defaults to forward so a never-searched buffer’s n still walks downward.

§jump_back: Vec<(usize, usize)>

Back half of the jumplist — Ctrl-o pops from here. Populated with the pre-motion cursor when a “big jump” motion fires (gg/G, %, */#, n/N, H/M/L, committed / or ?). Capped at 100 entries.

§jump_fwd: Vec<(usize, usize)>

Forward half — Ctrl-i pops from here. Cleared by any new big jump, matching vim’s “branch off trims forward history” rule.

§insert_pending_register: bool

Set by Ctrl-R in insert mode while waiting for the register selector. The next typed char names the register; its contents are inserted inline at the cursor and the flag clears.

§change_mark_start: Option<(usize, usize)>

Stashed start position for the [ mark on a Change operation. Set to top before the cut in run_operator_over_range (Change arm); consumed by finish_insert_session on Esc-from-insert when the reason is AfterChange. Mirrors vim’s :h '[ / :h '] rule that [ = start of change, ] = last typed char on exit.

§search_history: Vec<String>

Bounded history of committed / / ? search patterns. Newest entries are at the back; capped at [SEARCH_HISTORY_MAX] to avoid unbounded growth on long sessions.

§search_history_cursor: Option<usize>

Index into search_history while the user walks past patterns in the prompt via Ctrl-P / Ctrl-N. None outside that walk — typing or backspacing in the prompt resets it so the next Ctrl-P starts from the most recent entry again.

§last_input_at: Option<Instant>

Wall-clock instant of the last keystroke. Drives the :set timeoutlen multi-key timeout — if now() - last_input_at exceeds the configured budget, any pending prefix is cleared before the new key dispatches. None before the first key. 0.0.29 (Patch B): :set timeoutlen math now reads crate::types::Host::now via last_input_host_at. This Instant-flavoured field stays for snapshot tests that still observe it directly.

§last_input_host_at: Option<Duration>

Host::now() reading at the last keystroke. Drives :set timeoutlen so macro replay / headless drivers stay deterministic regardless of wall-clock skew.

§last_substitute: Option<SubstituteCmd>

Most recent successful :s invocation. Stored so :& / :&& can repeat it.

§pending_closes: Vec<(usize, usize, char)>

Stack of auto-inserted closing characters awaiting skip-over.

Each entry (row, col, ch) records where autopair placed a close character. When the next typed char matches ch AND the cursor is immediately before that position, the engine advances past it (“skip-over”) instead of inserting. The stack is cleared on any cursor motion, mode change, or out-of-pair edit.

§last_sneak: Option<((char, char), bool)>

Last sneak digraph and direction: Some(((c1, c2), forward)). Used by ; / , sneak-repeat when last_horizontal_motion == Sneak.

§last_horizontal_motion: LastHorizontalMotion

Tracks which kind of horizontal motion was last performed, so ; / , can dispatch to sneak-repeat vs. find-char-repeat as appropriate.

Implementations§

Source§

impl VimState

Source

pub fn public_mode(&self) -> VimMode

Source

pub fn force_normal(&mut self)

Source

pub fn is_visual(&self) -> bool

Source

pub fn is_visual_char(&self) -> bool

Trait Implementations§

Source§

impl Default for VimState

Source§

fn default() -> VimState

Returns the “default value” for a type. Read more

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more