Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions autoload/operator/replace.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions t/entire_buffer.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
runtime! plugin/operator/*.vim

describe '<Plug>(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\<Plug>(operator-replace)"
Expect line('$') == 1
Expect getline(1) ==# 'piyo poyo'
end
end