Vi mode add support for d0, d^, c0, and c^ (#459)

* Vi mode add support for d0, d^, c0, and c^

Also changes d$ to delete just current line for
multiline inputs

* Make `d0` line aware

* Make `c0` line aware

Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
This commit is contained in:
bnprks 2022-08-03 02:49:36 -07:00 committed by GitHub
parent f4aa6921b4
commit b750db6516
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -278,7 +278,7 @@ impl Command {
) -> Option<Vec<ReedlineOption>> { ) -> Option<Vec<ReedlineOption>> {
let edits = match self { let edits = match self {
Self::Delete => match motion { Self::Delete => match motion {
Motion::End => Some(vec![ReedlineOption::Edit(EditCommand::CutToEnd)]), Motion::End => Some(vec![ReedlineOption::Edit(EditCommand::CutToLineEnd)]),
Motion::Line => Some(vec![ReedlineOption::Edit(EditCommand::CutCurrentLine)]), Motion::Line => Some(vec![ReedlineOption::Edit(EditCommand::CutCurrentLine)]),
Motion::NextWord => { Motion::NextWord => {
Some(vec![ReedlineOption::Edit(EditCommand::CutWordRightToNext)]) Some(vec![ReedlineOption::Edit(EditCommand::CutWordRightToNext)])
@ -306,7 +306,7 @@ impl Command {
Motion::LeftBefore(c) => { Motion::LeftBefore(c) => {
Some(vec![ReedlineOption::Edit(EditCommand::CutLeftBefore(*c))]) Some(vec![ReedlineOption::Edit(EditCommand::CutLeftBefore(*c))])
} }
Motion::Start => None, Motion::Start => Some(vec![ReedlineOption::Edit(EditCommand::CutFromLineStart)]),
}, },
Self::Change => match motion { Self::Change => match motion {
Motion::End => Some(vec![ Motion::End => Some(vec![
@ -358,7 +358,10 @@ impl Command {
ReedlineOption::Edit(EditCommand::CutLeftBefore(*c)), ReedlineOption::Edit(EditCommand::CutLeftBefore(*c)),
ReedlineOption::Event(ReedlineEvent::Repaint), ReedlineOption::Event(ReedlineEvent::Repaint),
]), ]),
Motion::Start => None, Motion::Start => Some(vec![
ReedlineOption::Edit(EditCommand::CutFromLineStart),
ReedlineOption::Event(ReedlineEvent::Repaint),
]),
}, },
_ => None, _ => None,
}; };

View File

@ -33,7 +33,7 @@ where
let _ = input.next(); let _ = input.next();
Some(Motion::Line) Some(Motion::Line)
} }
Some('0') => { Some('0' | '^') => {
let _ = input.next(); let _ = input.next();
Some(Motion::Start) Some(Motion::Start)
} }