1

I have the following lines

autocmd filetype tex nmap <d-p-1>       cha
autocmd filetype tex nmap <d-p-2>       sec
autocmd filetype tex nmap <d-p-3>       sub
autocmd filetype tex nmap <d-p-4>       ssub
autocmd filetype tex nmap <d-p-5>       par
autocmd filetype tex nmap <d-p-6>       subp
autocmd filetype tex nmap <d-s-p-0> part*"
autocmd filetype tex nmap <d-s-p-1>     
autocmd filetype tex nmap <d-s-p-2> 
autocmd filetype tex nmap <d-s-p-3> 
autocmd filetype tex nmap <d-s-p-4> 
autocmd filetype tex nmap <d-s-p-5> 
autocmd filetype tex nmap <d-s-p-6> 

I selected the last words in the first 6 lines using visual-block, tried to copy and paste as block(using p or P, and it just creates lines like this:

    autocmd filetype tex nmap <d-p-1>       cha
    autocmd filetype tex nmap <d-p-2>       sec
    autocmd filetype tex nmap <d-p-3>       sub
    autocmd filetype tex nmap <d-p-4>       ssub
    autocmd filetype tex nmap <d-p-5>       par
    autocmd filetype tex nmap <d-p-6>       subp
    autocmd filetype tex nmap <d-s-p-0> part*"
    autocmd filetype tex nmap <d-s-p-1>     
cha
sec
sub
ssub
par
subp
    autocmd filetype tex nmap <d-s-p-2> 
    autocmd filetype tex nmap <d-s-p-3> 
    autocmd filetype tex nmap <d-s-p-4> 
    autocmd filetype tex nmap <d-s-p-5> 
    autocmd filetype tex nmap <d-s-p-6> 

This is the state of register after copying

after copying

I am using VimR and have

set clipboard+=unnamed
set go+=a
set cpoptions+=y

Why hasn't it worked?!?

update: It behaves the same in neovim binary(I am on macos). with -u NONE it works as intended.

Thanks

  • Did you press $ to extend the selection to the end of all lines? – B Layer Aug 17 at 22:19
  • of course, indeed – eyal karni Aug 17 at 22:19
  • What column did you start on? – B Layer Aug 17 at 22:21
  • I went to the c in "cha". I pressed ctrl-v then j 5 times until I was on s of "subp". then I pressed $ and y. – eyal karni Aug 17 at 22:23
  • I pressed p or P in the end of "autocmd filetype tex nmap <d-s-p-1>" – eyal karni Aug 17 at 22:24
3

The problem is with your clipboard setup:

set clipboard+=unnamed

I urge you to not use system clipboard as the default clipboard in Vim, it has multiple problems, including the problem you're facing right now. It's not a unknown matter that system clipboard doesn't handle block-style-texts, it only knows lines of texts.

Another example of problems that arise with using system clipboard as the default clipboard in Vim:

If you use clipboard in a recording, and you have set clipboard+=unnamed, your macro wouldn't run, it will exit with an error. There are many more. When you're doing much back-and-forth between system and Vim, just do manually :set clipboard=unnamed, and return to normal behavior afterwards. It would save you much hassle.

  • Thanks. But I disagree, working with the system clipboard is efficient. I consider this a bug in vim. But I might consider removing unnamed before such actions (which I seldom do) – eyal karni Aug 18 at 9:46
  • 1
    @eyalkarni, yes, it's a bug. And you can do the opposite of what I suggested, i.e. you can just use vim's clipboard when system clipboard messes up and system clipboard otherwise, if your workflow requires that. And, just for the sake of saying, I don't think using system clipboard is efficient; but that comment heavily dependent on my own workflow; and that's also not the subject of this Q/A. Anyway, I hope you get a workaround, or better yet, I hope the bug gets fixed. – klaus Aug 18 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.