I'm creating a Vim script and a critical part of it is duplicating the selected lines. To duplicate lines, I have this mapping which works as intended:
vnoremap <Leader>d :copy '><CR>
But, when inside a function/script, the behavior of
copy seems different:
function Foo() copy '> endfunction
Sample Selected Lines
x = 'alpha' y = 'bravo' z = 'charlie'
x = 'alpha' y = 'bravo' z = 'charlie' x = 'alpha' y = 'bravo' z = 'charlie'
Actual Result (lines seem to be copied in reverse order)
x = 'alpha' y = 'bravo' z = 'charlie' z = 'charlie' y = 'bravo' x = 'alpha'
Likewise, running the
copy command manually against the selected lines works as expected:
Am I missing something? Are there better ways to duplicate selected lines programmatically? Thanks