diff --git a/autoload/operator/replace.vim b/autoload/operator/replace.vim index 42a9d75..bbd48c7 100644 --- a/autoload/operator/replace.vim +++ b/autoload/operator/replace.vim @@ -42,6 +42,14 @@ function! operator#replace#do(motion_wise) "{{{2 let original_selection = &g:selection let &g:selection = 'inclusive' execute 'normal!' '`['.visual_command.'`]"_d' + + " Work around + " When regtype is linewise and text object is entire buffer, remove + " blank line after pasting + if getregtype(register) ==# 'V' && getline(1, '$') == [''] + let put_command .= '`[k"_dd' + endif + let &g:selection = original_selection end execute 'normal!' '"'.register.put_command diff --git a/t/entire_buffer.vim b/t/entire_buffer.vim new file mode 100644 index 0000000..2ddd0f9 --- /dev/null +++ b/t/entire_buffer.vim @@ -0,0 +1,19 @@ +runtime! plugin/operator/*.vim + +describe '(operator-replace)' + before + new + call setline(1, 'hoge huga poyo') + end + + after + close! + end + + it 'works properly when regtype is V and object is entire buffer' + call setreg('s', 'piyo poyo', 'V') + execute 'normal' "V\"s\(operator-replace)" + Expect line('$') == 1 + Expect getline(1) ==# 'piyo poyo' + end +end