diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 81cf0163e69c..48e0d2e3a5a7 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -296,6 +296,8 @@ impl MappableCommand { delete_selection, "Delete selection", delete_selection_noyank, "Delete selection without yanking", change_selection, "Change selection", + change_selection_with_indent, "Change selection and place the cursor at the appropriated indent", + change_selection_with_indent_noyank, "Change selection without yanking and place the cursor at the appropriated indent", change_selection_noyank, "Change selection without yanking", collapse_selection, "Collapse selection into single cursor", flip_selections, "Flip selection cursor and anchor", @@ -2313,6 +2315,7 @@ fn shrink_to_line_bounds(cx: &mut Context) { enum Operation { Delete, Change, + ChangeWithIndent, } fn only_whole_lines(selection: &Selection, text: &Rope) -> bool { @@ -2354,6 +2357,9 @@ fn delete_selection_impl(cx: &mut Context, op: Operation) { exit_select_mode(cx); } Operation::Change => { + enter_insert_mode(cx); + } + Operation::ChangeWithIndent => { if only_whole_lines { open_above(cx); } else { @@ -2427,6 +2433,15 @@ fn change_selection_noyank(cx: &mut Context) { delete_selection_impl(cx, Operation::Change); } +fn change_selection_with_indent(cx: &mut Context) { + delete_selection_impl(cx, Operation::ChangeWithIndent); +} + +fn change_selection_with_indent_noyank(cx: &mut Context) { + cx.register = Some('_'); + delete_selection_impl(cx, Operation::ChangeWithIndent); +} + fn collapse_selection(cx: &mut Context) { let (view, doc) = current!(cx.editor); let text = doc.text().slice(..);