Added vims paste before (#1251)

This commit is contained in:
LukaOber 2022-09-22 22:17:20 +02:00 committed by GitHub
parent c4505878ad
commit d6f126695a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View File

@ -383,6 +383,11 @@ key = "p"
command = "paste" command = "paste"
mode = "nv" mode = "nv"
[[keymaps]]
key = "shift+p"
command = "paste_before"
mode = "nv"
[[keymaps]] [[keymaps]]
key = "shift+j" key = "shift+j"
command = "join_lines" command = "join_lines"

View File

@ -67,6 +67,8 @@ pub enum EditCommand {
Yank, Yank,
#[strum(serialize = "paste")] #[strum(serialize = "paste")]
Paste, Paste,
#[strum(serialize = "paste_before")]
PasteBefore,
#[strum(serialize = "normal_mode")] #[strum(serialize = "normal_mode")]
NormalMode, NormalMode,

View File

@ -965,6 +965,16 @@ pub fn do_edit<T: Clipboard>(
let data = register.unnamed.clone(); let data = register.unnamed.clone();
Self::do_paste(cursor, buffer, &data) Self::do_paste(cursor, buffer, &data)
} }
PasteBefore => {
let offset = cursor.offset();
let line = buffer.line_of_offset(offset);
let line_offset = buffer.offset_of_line(line);
let data = register.unnamed.clone();
if offset > line_offset {
cursor.set_offset(offset - 1, false, false);
}
Self::do_paste(cursor, buffer, &data)
}
NewLineAbove => { NewLineAbove => {
let offset = cursor.offset(); let offset = cursor.offset();
let line = buffer.line_of_offset(offset); let line = buffer.line_of_offset(offset);