@@ -187,6 +187,7 @@ impl Command {
187 copy_selection_on_prev_line, "Copy selection on previous line",
187 copy_selection_on_prev_line, "Copy selection on previous line",
188 move_next_word_start, "Move to beginning of next word",
188 move_next_word_start, "Move to beginning of next word",
189 move_prev_word_start, "Move to beginning of previous word",
189 move_prev_word_start, "Move to beginning of previous word",
190+ move_prev_word_end, "Move to end of previous word",
190 move_next_word_end, "Move to end of next word",
191 move_next_word_end, "Move to end of next word",
191 move_next_long_word_start, "Move to beginning of next long word",
192 move_next_long_word_start, "Move to beginning of next long word",
192 move_prev_long_word_start, "Move to beginning of previous long word",
193 move_prev_long_word_start, "Move to beginning of previous long word",
@@ -284,6 +285,9 @@ impl Command {
284 delete_char_backward, "Delete previous char",
285 delete_char_backward, "Delete previous char",
285 delete_char_forward, "Delete next char",
286 delete_char_forward, "Delete next char",
286 delete_word_backward, "Delete previous word",
287 delete_word_backward, "Delete previous word",
288+ delete_word_forward, "Delete next word",
289+ kill_to_line_start, "Delete content till the start of the line",
290+ kill_to_line_end, "Delete content till the end of the line",
287 undo, "Undo change",
291 undo, "Undo change",
288 redo, "Redo change",
292 redo, "Redo change",
289 earlier, "Move backward in history",
293 earlier, "Move backward in history",
@@ -330,6 +334,7 @@ impl Command {
330 wclose, "Close window",
334 wclose, "Close window",
331 wonly, "Current window only",
335 wonly, "Current window only",
332 select_register, "Select register",
336 select_register, "Select register",
337+ insert_register, "Insert register",
333 align_view_middle, "Align view middle",
338 align_view_middle, "Align view middle",
334 align_view_top, "Align view top",
339 align_view_top, "Align view top",
335 align_view_center, "Align view center",
340 align_view_center, "Align view center",
@@ -572,6 +577,29 @@ fn extend_to_line_start(cx: &mut Context) {
572 goto_line_start_impl(view, doc, Movement::Extend)
577 goto_line_start_impl(view, doc, Movement::Extend)
580+fn kill_to_line_start(cx: &mut Context) {
581+ let (view, doc) = current!(cx.editor);
582+ let text = doc.text().slice(..);
584+ let selection = doc.selection(view.id).clone().transform(|range| {
585+ let line = range.cursor_line(text);
586+ range.put_cursor(text, text.line_to_char(line), true)
588+ delete_selection_insert_mode(doc, view, &selection);
591+fn kill_to_line_end(cx: &mut Context) {
592+ let (view, doc) = current!(cx.editor);
593+ let text = doc.text().slice(..);
595+ let selection = doc.selection(view.id).clone().transform(|range| {
596+ let line = range.cursor_line(text);
597+ let pos = line_end_char_index(&text, line);
598+ range.put_cursor(text, pos, true)
600+ delete_selection_insert_mode(doc, view, &selection);
575fn goto_first_nonwhitespace(cx: &mut Context) {
603fn goto_first_nonwhitespace(cx: &mut Context) {
576 let (view, doc) = current!(cx.editor);
604 let (view, doc) = current!(cx.editor);
577 let text = doc.text().slice(..);
605 let text = doc.text().slice(..);
@@ -684,6 +712,10 @@ fn move_prev_word_start(cx: &mut Context) {
684 move_word_impl(cx, movement::move_prev_word_start)
712 move_word_impl(cx, movement::move_prev_word_start)
715+fn move_prev_word_end(cx: &mut Context) {
716+ move_word_impl(cx, movement::move_prev_word_end)
687fn move_next_word_end(cx: &mut Context) {
719fn move_next_word_end(cx: &mut Context) {
688 move_word_impl(cx, movement::move_next_word_end)
720 move_word_impl(cx, movement::move_next_word_end)
@@ -1586,6 +1618,17 @@ fn delete_selection_impl(reg: &mut Register, doc: &mut Document, view_id: ViewId
1586 doc.apply(&transaction, view_id);
1618 doc.apply(&transaction, view_id);
1622+fn delete_selection_insert_mode(doc: &mut Document, view: &View, selection: &Selection) {
1623+ let view_id = view.id;
1626+ let transaction = Transaction::change_by_selection(doc.text(), selection, |range| {
1627+ (range.from(), range.to(), None)
1629+ doc.apply(&transaction, view_id);
1589fn delete_selection(cx: &mut Context) {
1632fn delete_selection(cx: &mut Context) {
1590 let reg_name = cx.register.unwrap_or('"');
1633 let reg_name = cx.register.unwrap_or('"');
1591 let (view, doc) = current!(cx.editor);
1634 let (view, doc) = current!(cx.editor);
@@ -4010,8 +4053,19 @@ pub mod insert {
4010 .selection(view.id)
4053 .selection(view.id)
4011 .clone()
4054 .clone()
4012 .transform(|range| movement::move_prev_word_start(text, range, count));
4055 .transform(|range| movement::move_prev_word_start(text, range, count));
4013− doc.set_selection(view.id, selection);
4056+ delete_selection_insert_mode(doc, view, &selection);
4014− delete_selection(cx)
4057+ }
4059+ pub fn delete_word_forward(cx: &mut Context) {
4060+ let count = cx.count();
4061+ let (view, doc) = current!(cx.editor);
4062+ let text = doc.text().slice(..);
4064+ let selection = doc
4065+ .selection(view.id)
4067+ .transform(|range| movement::move_next_word_start(text, range, count));
4068+ delete_selection_insert_mode(doc, view, &selection);
@@ -4973,6 +5027,15 @@ fn select_register(cx: &mut Context) {
5030+fn insert_register(cx: &mut Context) {
5031+ cx.on_next_key(move |cx, event| {
5032+ if let Some(ch) = event.char() {
5033+ cx.editor.selected_register = Some(ch);
4976fn align_view_top(cx: &mut Context) {
5039fn align_view_top(cx: &mut Context) {
4977 let (view, doc) = current!(cx.editor);
5040 let (view, doc) = current!(cx.editor);
4978 align_view(doc, view, Align::Top);
5041 align_view(doc, view, Align::Top);