@@ -172,6 +172,8 @@ impl Command {
172172 extend_char_right, "Extend right",
173173 extend_line_up, "Extend up",
174174 extend_line_down, "Extend down",
175+ copy_selection_on_next_line, "Copy selection on next line",
176+ copy_selection_on_prev_line, "Copy selection on previous line",
175177 move_next_word_start, "Move to beginning of next word",
176178 move_prev_word_start, "Move to beginning of previous word",
177179 move_next_word_end, "Move to end of next word",
@@ -958,6 +960,34 @@ fn extend_char_right(cx: &mut Context) {
958960 doc.set_selection(view.id, selection);
959961}
960962
963+fn copy_selection_on_prev_line(cx: &mut Context) {
964+ let count = cx.count();
965+ let (view, doc) = current!(cx.editor);
966+ let text = doc.text().slice(..);
967+ let old_selection = doc.selection(view.id).clone();
968+ let mut ranges: SmallVec<_> = old_selection.ranges().into();
969+ for r in old_selection.iter() {
970+ ranges.push(Range::point(
971+ movement::move_vertically(text, *r, Direction::Backward, count, Movement::Extend).head,
972+ ));
973+ }
974+ doc.set_selection(view.id, Selection::new(ranges, old_selection.cursor()));
975+}
976+
977+fn copy_selection_on_next_line(cx: &mut Context) {
978+ let count = cx.count();
979+ let (view, doc) = current!(cx.editor);
980+ let text = doc.text().slice(..);
981+ let old_selection = doc.selection(view.id).clone();
982+ let mut ranges: SmallVec<_> = old_selection.ranges().into();
983+ for r in old_selection.iter() {
984+ ranges.push(Range::point(
985+ movement::move_vertically(text, *r, Direction::Forward, count, Movement::Extend).head,
986+ ));
987+ }
988+ doc.set_selection(view.id, Selection::new(ranges, old_selection.cursor()));
989+}
990+
961991fn extend_line_up(cx: &mut Context) {
962992 let count = cx.count();
963993 let (view, doc) = current!(cx.editor);