Add <a-c> and <a-d> for changing/deleting without yanking
As asked for in #1175
This commit is contained in:
parent
42e5d95cd8
commit
81b5de6fd8
|
@ -406,6 +406,9 @@ Changes
|
||||||
* `.`: repeat last insert mode change (`i`, `a`, or `c`, including
|
* `.`: repeat last insert mode change (`i`, `a`, or `c`, including
|
||||||
the inserted text)
|
the inserted text)
|
||||||
|
|
||||||
|
* `<a-d>`: delete current selection
|
||||||
|
* `<a-c>`: delete current selection and enter insert mode
|
||||||
|
|
||||||
* `I`: enter insert mode at current selection begin line start
|
* `I`: enter insert mode at current selection begin line start
|
||||||
* `A`: enter insert mode at current selection end line end
|
* `A`: enter insert mode at current selection end line end
|
||||||
* `o`: enter insert mode in one (or given count) new lines below
|
* `o`: enter insert mode in one (or given count) new lines below
|
||||||
|
|
|
@ -222,6 +222,12 @@ Changes
|
||||||
repeat last insert mode change (*i*, *a*, or *c*, including the
|
repeat last insert mode change (*i*, *a*, or *c*, including the
|
||||||
inserted text)
|
inserted text)
|
||||||
|
|
||||||
|
*<a-d>*::
|
||||||
|
delete current selection (not yanking)
|
||||||
|
|
||||||
|
*<a-c>*::
|
||||||
|
delete current selection and enter insert mode (not yanking)
|
||||||
|
|
||||||
*I*::
|
*I*::
|
||||||
enter insert mode at current selection begin line start
|
enter insert mode at current selection begin line start
|
||||||
|
|
||||||
|
|
|
@ -559,19 +559,27 @@ void yank(Context& context, NormalParams params)
|
||||||
get_face("Information") });
|
get_face("Information") });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<bool yank>
|
||||||
void erase_selections(Context& context, NormalParams params)
|
void erase_selections(Context& context, NormalParams params)
|
||||||
|
{
|
||||||
|
if (yank)
|
||||||
{
|
{
|
||||||
const char reg = params.reg ? params.reg : '"';
|
const char reg = params.reg ? params.reg : '"';
|
||||||
RegisterManager::instance()[reg].set(context, context.selections_content());
|
RegisterManager::instance()[reg].set(context, context.selections_content());
|
||||||
|
}
|
||||||
ScopedEdition edition(context);
|
ScopedEdition edition(context);
|
||||||
context.selections().erase();
|
context.selections().erase();
|
||||||
context.selections().avoid_eol();
|
context.selections().avoid_eol();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<bool yank>
|
||||||
void change(Context& context, NormalParams params)
|
void change(Context& context, NormalParams params)
|
||||||
|
{
|
||||||
|
if (yank)
|
||||||
{
|
{
|
||||||
const char reg = params.reg ? params.reg : '"';
|
const char reg = params.reg ? params.reg : '"';
|
||||||
RegisterManager::instance()[reg].set(context, context.selections_content());
|
RegisterManager::instance()[reg].set(context, context.selections_content());
|
||||||
|
}
|
||||||
enter_insert_mode<InsertMode::Replace>(context, params);
|
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('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>} },
|
{ {alt('F')}, {"extend to previous character included", select_to_next_char<SelectFlags::Inclusive | SelectFlags::Extend | SelectFlags::Reverse>} },
|
||||||
|
|
||||||
{ {'d'}, {"erase selected text", erase_selections} },
|
{ {'d'}, {"erase selected text", erase_selections<true>} },
|
||||||
{ {'c'}, {"change selected text", change} },
|
{ {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 before selected text", enter_insert_mode<InsertMode::Insert>} },
|
||||||
{ {'I'}, {"insert at line begin", enter_insert_mode<InsertMode::InsertAtLineBegin>} },
|
{ {'I'}, {"insert at line begin", enter_insert_mode<InsertMode::InsertAtLineBegin>} },
|
||||||
{ {'a'}, {"insert after selected text", enter_insert_mode<InsertMode::Append>} },
|
{ {'a'}, {"insert after selected text", enter_insert_mode<InsertMode::Append>} },
|
||||||
|
|
Loading…
Reference in New Issue
Block a user