svermeulen / vim-easyclip

Simplified clipboard functionality for Vim
689 stars 21 forks source link

paste: don't add blank line when pasting linewise to whole buffer #90

Closed Coacher closed 7 years ago

Coacher commented 8 years ago

A bit of mish-mash with PR #89. I can reduce this to a single commit later rather than fix conflicts.

Coacher commented 8 years ago

Example file:

123
456
789

Steps to reproduce the problem: VGygvp

Actual results (notice extra blank line at the beginning):


123
456
789

Expected results:

123
456
789
Coacher commented 8 years ago

It turns out linewise Visual pasting has this unique feature when pasting to an empty buffer: it preserves the empty line that is already in the buffer. This leads to problems when pasting over the whole buffer in linewise Visual mode because "_d is called before actual pasting, which leaves us with an empty buffer. Workaround it by reselecting this single empty line. This is also how default Vim behaves (it doesn't produce any extra blank lines).

Characterwise and blockwise modes are unaffected.

Coacher commented 8 years ago

Again similar problem affects XG_EasyClipPaste, but there's no such simple fix for that.

svermeulen commented 7 years ago

Thanks for this. Sorry it took me so long to merge!