From 21464d1f463faa94eda8a8a6214eb45e7bbcdc4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Lasersk=C3=B6ld?= Date: Wed, 1 Nov 2023 22:38:23 +0100 Subject: [PATCH] s --- src/modes/normalmode.cpp | 1 + src/script/standardcommands.cpp | 32 ++++++++++++++++++++++++-------- src/script/standardcommands.h | 1 + 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/modes/normalmode.cpp b/src/modes/normalmode.cpp index 761913b..a9890ca 100644 --- a/src/modes/normalmode.cpp +++ b/src/modes/normalmode.cpp @@ -51,6 +51,7 @@ std::shared_ptr createNormalMode() { {{"I"}, sc.combine(sc.home, sc.insert_mode)}, {{"a"}, sc.combine(sc.right, sc.insert_mode)}, {{"A"}, sc.combine(sc.end, sc.insert_mode)}, + {{"s"}, sc.combine(sc.erase_after, sc.insert_mode)}, {{">"}, {sc.indent}}, {{"<"}, {sc.deindent}}, }, diff --git a/src/script/standardcommands.cpp b/src/script/standardcommands.cpp index 1dca938..161869a 100644 --- a/src/script/standardcommands.cpp +++ b/src/script/standardcommands.cpp @@ -191,20 +191,36 @@ StandardCommands create() { auto &e = env->editor(); auto selection = e.selection(); if (selection.empty()) { - env->registers().save(standardRegister, - content(e.cursor()).toString()); - e.cursor(erase(e.cursor())); - } - else { auto str = std::string{}; - // REPEAT { - str += toString(selection); + REPEAT { + str = toString(e.cursor()) + str; + e.cursor(erase(e.cursor())); + } + env->registers().save(standardRegister, str); + } + else { + env->registers().save(standardRegister, toString(selection)); e.cursor(erase(selection), true); - // } + } + }; + DEF(erase_after) { + auto &e = env->editor(); + auto selection = e.selection(); + if (selection.empty()) { + auto str = std::string{}; + + REPEAT { + str += toString(e.cursor()); + e.cursor(erase(right(e.cursor()))); + } env->registers().save(standardRegister, str); } + else { + env->registers().save(standardRegister, toString(selection)); + e.cursor(erase(selection), true); + } }; DEF(erase_before_word) { diff --git a/src/script/standardcommands.h b/src/script/standardcommands.h index c2308e9..9051ceb 100644 --- a/src/script/standardcommands.h +++ b/src/script/standardcommands.h @@ -28,6 +28,7 @@ STD_DEF(yank) \ STD_DEF(yank_block) \ STD_DEF(erase) \ + STD_DEF(erase_after) \ STD_DEF(erase_before_word) \ STD_DEF(paste_before) \ STD_DEF(paste) \