pub enum Motion {
Char(Direction),
Line(Direction),
Word {
direction: Direction,
boundary: WordBoundary,
end: bool,
},
LinePosition(LinePosition),
Paragraph(Direction),
FindChar {
char: char,
direction: Direction,
till: bool,
},
JumpLine(Option<usize>),
MatchBracket,
}Expand description
Motion types for cursor movement.
Each variant represents a different type of cursor motion that vim supports. Motions can be used with operators (d, y, c) or on their own for navigation.
§Example
use reovim_kernel::api::v1::*;
// Character motion (h, l)
let left = Motion::Char(Direction::Backward);
let right = Motion::Char(Direction::Forward);
// Word motion (w, b, e)
let word_forward = Motion::Word {
direction: Direction::Forward,
boundary: WordBoundary::Word,
end: false,
};Variants§
Char(Direction)
Character motion (h, l)
Line(Direction)
Line motion (j, k)
Word
Word motion (w, b, e, ge, W, B, E, gE)
Fields
§
boundary: WordBoundaryWord boundary type (word vs WORD)
LinePosition(LinePosition)
Line position (0, ^, $, g_)
Paragraph(Direction)
Paragraph motion ({, })
FindChar
Find character on line (f, F, t, T)
Fields
JumpLine(Option<usize>)
Jump to line (G, gg)
None- jump to last line (G) or first line (gg)Some(n)- jump to line n (1-indexed in vim, 0-indexed internally)
MatchBracket
Match bracket (%)
Implementations§
Source§impl Motion
impl Motion
Sourcepub const fn is_linewise(&self) -> bool
pub const fn is_linewise(&self) -> bool
Check if this motion is linewise.
Linewise motions operate on whole lines rather than character ranges. This affects how operators (d, y, c) interpret the motion.
§Example
djdeletes current line and next line (linewise)dwdeletes to start of next word (characterwise)
Sourcepub const fn is_inclusive(&self) -> bool
pub const fn is_inclusive(&self) -> bool
Check if this motion is inclusive.
Inclusive motions include the character at the target position. This affects operators like delete and yank.
§Example
d$deletes to end of line including the last character (inclusive)dwdeletes to start of next word excluding the first character (exclusive)
Trait Implementations§
impl Copy for Motion
impl Eq for Motion
impl StructuralPartialEq for Motion
Auto Trait Implementations§
impl Freeze for Motion
impl RefUnwindSafe for Motion
impl Send for Motion
impl Sync for Motion
impl Unpin for Motion
impl UnsafeUnpin for Motion
impl UnwindSafe for Motion
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more