Vim: substitute support (#2641)

Release Notes:

- vim mode now supports `s` for substitute
This commit is contained in:
Max Brunsfeld 2023-06-23 12:58:14 -07:00 committed by GitHub
commit 030984dca4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 82 additions and 2 deletions

View file

@ -1,5 +1,6 @@
mod change;
mod delete;
mod substitute;
mod yank;
use std::{borrow::Cow, cmp::Ordering, sync::Arc};
@ -25,6 +26,7 @@ use workspace::Workspace;
use self::{
change::{change_motion, change_object},
delete::{delete_motion, delete_object},
substitute::substitute,
yank::{yank_motion, yank_object},
};
@ -45,6 +47,7 @@ actions!(
DeleteToEndOfLine,
Paste,
Yank,
Substitute,
]
);
@ -56,6 +59,12 @@ pub fn init(cx: &mut AppContext) {
cx.add_action(insert_end_of_line);
cx.add_action(insert_line_above);
cx.add_action(insert_line_below);
cx.add_action(|_: &mut Workspace, _: &Substitute, cx| {
Vim::update(cx, |vim, cx| {
let times = vim.pop_number_operator(cx);
substitute(vim, times, cx);
})
});
cx.add_action(|_: &mut Workspace, _: &DeleteLeft, cx| {
Vim::update(cx, |vim, cx| {
let times = vim.pop_number_operator(cx);