pub enum TextObject {
NextMatch,
PrevMatch,
Line,
Word {
around: bool,
},
Delimited {
open: char,
close: char,
around: bool,
},
}Expand description
A text EXTENT an operator can act over, as opposed to a point it moves to.
vim’s gn is the motivating case and shows why the distinction matters:
dgn deletes the next match wherever it is, including when the cursor is
nowhere near it. Modelled as a motion it would resolve to the match’s start
and the operator would act over [cursor, match.start) — deleting the text
BEFORE the match instead of the match. Same keys, opposite effect.
Closed, so an unhandled object cannot reach the executor.
Variants§
NextMatch
gn — the next search match at or after the cursor.
PrevMatch
gN — the previous search match at or before the cursor.
Line
dd / cc / yy — the current line, LINEWISE.
A doubled operator in vim acts on whole lines, trailing newline included, which is why this is an object rather than a motion: there is no cursor-to-target range that expresses “this line and its terminator” without special-casing the last line.
Word
iw / aw — the word under the cursor.
around: true takes the trailing run of whitespace as well, which is
the whole difference vim draws between diw and daw.
Delimited
i( a{ i" … — the region between a matched pair.
One variant covers brackets and quotes because the only thing that
differs is whether the delimiters nest; carrying open/close
separately lets a quote say open == close instead of needing its
own arm.
Implementations§
Source§impl TextObject
impl TextObject
Sourcepub const fn register_kind(self) -> RegisterKind
pub const fn register_kind(self) -> RegisterKind
How an operator over this object leaves the register — and therefore
how a later p replays it.
Total over TextObject, no wildcard arm. The mapping lives here,
beside the variants, rather than at the one call site that needs it
today: a new linewise object (vim’s ip/ap paragraph objects are the
obvious next ones) must decide, and a wildcard would silently answer
Charwise for them — the direction that pastes a paragraph into the
middle of whatever line the cursor happens to be on.
Trait Implementations§
Source§impl Clone for TextObject
impl Clone for TextObject
impl Copy for TextObject
Source§impl Debug for TextObject
impl Debug for TextObject
Source§impl<'de> Deserialize<'de> for TextObject
impl<'de> Deserialize<'de> for TextObject
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for TextObject
Source§impl Hash for TextObject
impl Hash for TextObject
Source§impl JsonSchema for TextObject
impl JsonSchema for TextObject
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read more