vim: Add Multi Replace mode in Vim (#8469)
For #4440, I've only added support for normal, if it's visual mode, would we like this to delete the current selection row and enter insert mode? --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
parent
72d36d0213
commit
e836a979a2
12 changed files with 584 additions and 16 deletions
|
@ -10,6 +10,7 @@ mod mode_indicator;
|
|||
mod motion;
|
||||
mod normal;
|
||||
mod object;
|
||||
mod replace;
|
||||
mod state;
|
||||
mod utils;
|
||||
mod visual;
|
||||
|
@ -29,6 +30,7 @@ use language::{CursorShape, Point, Selection, SelectionGoal, TransactionId};
|
|||
pub use mode_indicator::ModeIndicator;
|
||||
use motion::Motion;
|
||||
use normal::normal_replace;
|
||||
use replace::multi_replace;
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
use serde_derive::Serialize;
|
||||
|
@ -132,6 +134,7 @@ fn register(workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) {
|
|||
insert::register(workspace, cx);
|
||||
motion::register(workspace, cx);
|
||||
command::register(workspace, cx);
|
||||
replace::register(workspace, cx);
|
||||
object::register(workspace, cx);
|
||||
visual::register(workspace, cx);
|
||||
}
|
||||
|
@ -418,6 +421,11 @@ impl Vim {
|
|||
if selection.is_empty() {
|
||||
selection.end = movement::right(map, selection.start);
|
||||
}
|
||||
} else if last_mode == Mode::Replace {
|
||||
if selection.head().column() != 0 {
|
||||
let point = movement::left(map, selection.head());
|
||||
selection.collapse_to(point, selection.goal)
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
|
@ -608,7 +616,10 @@ impl Vim {
|
|||
Mode::Visual | Mode::VisualLine | Mode::VisualBlock => visual_replace(text, cx),
|
||||
_ => Vim::update(cx, |vim, cx| vim.clear_operator(cx)),
|
||||
},
|
||||
_ => {}
|
||||
_ => match Vim::read(cx).state().mode {
|
||||
Mode::Replace => multi_replace(text, cx),
|
||||
_ => {}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue