Skip to content

VimStateVim

Unofficial

Vim’s state for one editor: which mode it is in, the command being typed, and everything needed to repeat the last edit.

The optional fields are absent until the feature that owns them is first used — an editor that has never searched has no search state, and one that has never left visual mode has no last selection.

Import:

import type { VimStateVim } from '@obsidian-typings/obsidian-public-latest';

Signature:

export interface VimStateVim

Properties

PropertyTypeDescription
exMode?booleanWhether the Ex prompt is open.
expectLiteralNextbooleanWhether the next key is taken literally, which is how f and r read their argument through a langmap.
inputStateVimInputStateThe command currently being typed.
insertEnd?BookmarkWhere the current insertion ends, tracked so the inserted text can be found again after the document changes.
insertModebooleanWhether the editor is in insert mode.
insertModeRepeat?numberHow many times the insertion is repeated when insert mode is left, as 3i asks for. Only set while insert mode is active.
insertModeReturnbooleanWhether leaving insert mode returns to the mode it was entered from rather than to normal mode.
lastEditActionCommand?VimActionKeyMappingThe action command behind the last edit, replayed by ..
lastEditInputState?VimInputStateThe input state that produced the last edit, replayed by ..
lastHPosnumberThe column the cursor should return to when moving between lines shorter than it.
lastHSPosnumberThe screen column the cursor should return to, which is what gj and gk move by.
lastMotionnull | VimMotionFnThe motion that ran last, cleared as soon as a non-motion command runs.
lastPastedTextnull | stringThe text pasted last, so a following paste can find what it replaced.
lastSelectionnull | VimLastSelectionThe visual selection as it was when visual mode was last left, restored by gv.
marksRecord<string, Bookmark>The marks set in this editor, keyed by their one-character name.
optionsRecord<string, VimOption>The options set for this editor only, which override the global ones.
searchState_?VimSearchStateThe search state for this editor. Absent until the first search.
selVimSelectionThe selection Vim is maintaining, which is empty until the first motion runs.
status?stringThe key sequence shown in the status area while a command is being typed.
visualBlockbooleanWhether the editor is in visual block mode. No effect unless visualMode is set.
visualLinebooleanWhether the editor is in visual line mode. No effect unless visualMode is set.
visualModebooleanWhether the editor is in visual mode.
wasInVisualBlock?booleanWhether the selection that visual mode was just left from was a block, which operators consult after the mode has already been left.

Methods

MethodReturnsDescription
onPasteFn()voidThe paste handler installed on the editor's input field while Vim mode is on.

Links to this page: