From 2d468b746299a9f580c8c5c55122e222df6c78b6 Mon Sep 17 00:00:00 2001 From: metiftikci Date: Fri, 27 Oct 2023 14:51:08 +0300 Subject: [PATCH] feat: add substitute --- src/buffer/maps.rs | 1 + src/buffer/operations.rs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/buffer/maps.rs b/src/buffer/maps.rs index 93f5da5..21a1acc 100644 --- a/src/buffer/maps.rs +++ b/src/buffer/maps.rs @@ -43,6 +43,7 @@ pub fn get_default_normal_maps() -> ActionMap { map.insert("N", buffer_action!(move_to_previous_find)); // operations + map.insert("s", buffer_action!(substitute_char)); map.insert("x", buffer_action!(delete_char)); map.insert("J", buffer_action!(join_lines_cursor)); map.insert("O", buffer_action!(open_new_line_previous)); diff --git a/src/buffer/operations.rs b/src/buffer/operations.rs index 27686b1..71b8c87 100644 --- a/src/buffer/operations.rs +++ b/src/buffer/operations.rs @@ -68,6 +68,11 @@ impl Buffer { .unwrap(); } + pub fn substitute_char(&mut self) { + self.delete_char(); + self.enter_insert_mode(); + } + fn insert_line(&mut self, row: usize) { self.lines.insert(row, String::new()); self.set_size(self.area.clone());