Skip to main content

Stmt

Enum Stmt 

Source
pub enum Stmt {
Show 32 variants Echo(Vec<Expr>), Echon(Vec<Expr>), Let { target: LetTarget, expr: Expr, }, Call(Expr), Expr(Expr), If { arms: Vec<(Expr, Vec<Stmt>)>, else_body: Option<Vec<Stmt>>, }, While { cond: Expr, body: Vec<Stmt>, }, For { vars: ForVars, iter: Expr, body: Vec<Stmt>, }, Break, Continue, Finish, Return(Option<Expr>), Function { name: String, args: Vec<String>, defaults: Vec<(usize, Expr)>, body: Vec<Stmt>, bang: bool, vim9: bool, }, Try { body: Vec<Stmt>, catches: Vec<(Option<String>, Vec<Stmt>)>, finally: Option<Vec<Stmt>>, }, Throw(Expr), Execute(Vec<Expr>), Set(String), Source(String), Unlet(Vec<UnletArg>), Map(String), CommandDef(String), CommandDel(String), DelFunction(String), UserCmd(String), Autocmd(String), Augroup(String), Doautocmd(String), ExCmd(String), Colorscheme(String), Highlight(String), Syntax(String), Filetype(String),
}
Expand description

A Vimscript statement (one ex-command’s worth of work).

Variants§

§

Echo(Vec<Expr>)

:echo expr ….

§

Echon(Vec<Expr>)

:echon expr ….

§

Let

:let target = expr.

Fields

§target: LetTarget

Assignment target.

§expr: Expr

Value expression.

§

Call(Expr)

:call funcref(args).

§

Expr(Expr)

A bare expression (REPL / -e).

§

If

:if … :elseif … :else … :endif. Each arm is (condition, body); the optional trailing else body has no condition.

Fields

§arms: Vec<(Expr, Vec<Stmt>)>

if / elseif arms in source order.

§else_body: Option<Vec<Stmt>>

else body, if present.

§

While

:while {cond} … :endwhile.

Fields

§cond: Expr

Loop condition.

§body: Vec<Stmt>

Loop body.

§

For

:for {var} in {expr} … :endfor (list iteration).

Fields

§vars: ForVars

Loop variable(s) — a single name or a [a, b] unpack.

§iter: Expr

Iterable expression (a List in Phase 3 of this port).

§body: Vec<Stmt>

Loop body.

§

Break

:break.

§

Continue

:continue.

§

Finish

:finish — stop sourcing the rest of the current script/file.

§

Return(Option<Expr>)

:return [expr].

§

Function

:function {name}(args) … :endfunction.

Fields

§name: String

Function name (may be scoped / s: / autoload).

§args: Vec<String>

Parameter names (without the a: prefix).

§defaults: Vec<(usize, Expr)>

Default values for optional parameters: (param index, default expr), e.g. func F(a, b = 10) records (1, Num(10)). Evaluated at call time when the argument is omitted (:help optional-function-argument).

§body: Vec<Stmt>

Function body.

§bang: bool

function! — replace an existing definition.

§vim9: bool

true for a vim9 :def (bare names in the body resolve to script-scope vars/functions), false for a legacy :function.

§

Try

:try … :catch {pat} … :finally … :endtry.

Fields

§body: Vec<Stmt>

Protected body.

§catches: Vec<(Option<String>, Vec<Stmt>)>

catch clauses: (optional /pattern/, body).

§finally: Option<Vec<Stmt>>

finally body, always run.

§

Throw(Expr)

:throw {expr}.

§

Execute(Vec<Expr>)

:execute expr … — concatenate the values (space-separated) and run the result as an ex command line.

§

Set(String)

:set {args} — set options (the raw argument text).

§

Source(String)

:source {file} — read and run another .vim file in the current scope (its functions and globals persist). The raw (unquoted) filename.

§

Unlet(Vec<UnletArg>)

:unlet[!] {name}… — delete one or more variables, list items, or dict entries. Each argument is either a bare name or a List/Dict element target (l[i] / d.key); see UnletArg.

§

Map(String)

A :map-family command (nmap, inoremap, vunmap, mapclear, …): the whole raw command line, re-parsed by the mapping runtime.

§

CommandDef(String)

:command[!] [-attrs] Name {repl} — define a user command (raw args).

§

CommandDel(String)

:delcommand {name} — delete a user command.

§

DelFunction(String)

:delfunction[!] {name} — remove a user function from the registry. The raw argument (optional leading !, then the name) is resolved at run time, mirroring how :call/exists('*…') key the function table.

§

UserCmd(String)

Invocation of a user command (:Name args): the whole raw line, resolved against the user-command table at run time.

§

Autocmd(String)

:autocmd[!] {event} {pat} {cmd} — register an autocommand (raw args).

§

Augroup(String)

:augroup {name} / :augroup END — set the active autocommand group.

§

Doautocmd(String)

:doautocmd {event} [{pat}] — fire matching autocommands.

§

ExCmd(String)

A :-prefixed or %-prefixed Ex command line with an optional line range (:%s/…, :1,3d, %g/…/d): the whole raw line, parsed and run against the current buffer at run time.

§

Colorscheme(String)

:colorscheme {name} (:colo) — select a color scheme. Sources the matching colors/{name}.vim from the runtime path (firing its :highlight commands) and records g:colors_name. The raw name; empty for the bare :colorscheme query.

§

Highlight(String)

:highlight [default] {group} {key}={val}… (:hi) — define a highlight group. The raw argument text; parsed at run time into the highlight registry and mirrored to an embedding editor via the highlight host hook.

§

Syntax(String)

:syntax … (:syn) — syntax-highlighting control. Recognized so real vimrc files parse; the raw argument text is forwarded to an optional host hook (an embedding editor may enable its own highlighter) and is otherwise a no-op standalone.

§

Filetype(String)

:filetype … (:filet) — filetype-detection control. Recognized so real vimrc files parse; forwarded to an optional host hook and otherwise a no-op standalone.

Trait Implementations§

Source§

impl Clone for Stmt

Source§

fn clone(&self) -> Stmt

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 Stmt

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Stmt

§

impl RefUnwindSafe for Stmt

§

impl Send for Stmt

§

impl Sync for Stmt

§

impl Unpin for Stmt

§

impl UnsafeUnpin for Stmt

§

impl UnwindSafe for Stmt

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

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
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.
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