diff --git a/rc/filetype/c-family.kak b/rc/filetype/c-family.kak index f56d9db2..7ef1c975 100644 --- a/rc/filetype/c-family.kak +++ b/rc/filetype/c-family.kak @@ -390,7 +390,7 @@ define-command -hidden c-family-insert-include-guards %{ evaluate-commands %sh{ case "${kak_opt_c_include_guard_style}" in ifdef) - echo 'execute-keys ggi%ggI/xs^.*/dxs\.c_A_INCLUDEDggxyppI#ifndefjI#definejI#endif//O' + echo 'execute-keys gg"%PI/xs^.*/dxs\.r_A_INCLUDEDxyPPI#ifndefjI#definejI#endif//O' ;; pragma) echo 'execute-keys ggi#pragmaonce' diff --git a/src/normal.cc b/src/normal.cc index 51027529..e68db583 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -683,10 +683,13 @@ void paste(Context& context, NormalParams params) ScopedEdition edition(context); context.selections().for_each([&](size_t index, Selection& sel) { auto& str = strings[std::min(strings.size()-1, index)]; - if (mode == PasteMode::Replace) - replace(buffer, sel, str); - else - insert(buffer, sel, paste_pos(buffer, sel, mode, linewise), str); + auto& min = sel.min(); + auto& max = sel.max(); + BufferRange range = (mode == PasteMode::Replace) ? + buffer.replace(min, buffer.char_next(max), str) + : buffer.insert(paste_pos(buffer, sel, mode, linewise), str); + min = range.begin; + max = range.end > range.begin ? buffer.char_prev(range.end) : range.begin; }); }