summaryrefslogtreecommitdiff
path: root/src/normal.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-07-11 13:49:29 +0900
committerMaxime Coste <mawww@kakoune.org>2017-07-11 22:25:15 +0900
commit81b5de6fd86b4d1db25cf7e25f3e29bdb6ad9689 (patch)
treed3d91c4a345b9322a46c90128fb1294e3f649c7d /src/normal.cc
parent42e5d95cd80e7964e6b681deea633029d7ee4c1c (diff)
Add <a-c> and <a-d> for changing/deleting without yanking
As asked for in #1175
Diffstat (limited to 'src/normal.cc')
-rw-r--r--src/normal.cc22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/normal.cc b/src/normal.cc
index a8919e6e..97243508 100644
--- a/src/normal.cc
+++ b/src/normal.cc
@@ -559,19 +559,27 @@ void yank(Context& context, NormalParams params)
get_face("Information") });
}
+template<bool yank>
void erase_selections(Context& context, NormalParams params)
{
- const char reg = params.reg ? params.reg : '"';
- RegisterManager::instance()[reg].set(context, context.selections_content());
+ if (yank)
+ {
+ const char reg = params.reg ? params.reg : '"';
+ RegisterManager::instance()[reg].set(context, context.selections_content());
+ }
ScopedEdition edition(context);
context.selections().erase();
context.selections().avoid_eol();
}
+template<bool yank>
void change(Context& context, NormalParams params)
{
- const char reg = params.reg ? params.reg : '"';
- RegisterManager::instance()[reg].set(context, context.selections_content());
+ if (yank)
+ {
+ const char reg = params.reg ? params.reg : '"';
+ RegisterManager::instance()[reg].set(context, context.selections_content());
+ }
enter_insert_mode<InsertMode::Replace>(context, params);
}
@@ -1901,8 +1909,10 @@ const HashMap<Key, NormalCmd> keymap{
{ {alt('T')}, {"extend to previous character", select_to_next_char<SelectFlags::Extend | SelectFlags::Reverse>} },
{ {alt('F')}, {"extend to previous character included", select_to_next_char<SelectFlags::Inclusive | SelectFlags::Extend | SelectFlags::Reverse>} },
- { {'d'}, {"erase selected text", erase_selections} },
- { {'c'}, {"change selected text", change} },
+ { {'d'}, {"erase selected text", erase_selections<true>} },
+ { {alt('d')}, {"erase selected text, without yanking", erase_selections<false>} },
+ { {'c'}, {"change selected text", change<true>} },
+ { {alt('c')}, {"change selected text, without yanking", change<false>} },
{ {'i'}, {"insert before selected text", enter_insert_mode<InsertMode::Insert>} },
{ {'I'}, {"insert at line begin", enter_insert_mode<InsertMode::InsertAtLineBegin>} },
{ {'a'}, {"insert after selected text", enter_insert_mode<InsertMode::Append>} },