vim-yoink icon indicating copy to clipboard operation
vim-yoink copied to clipboard

[Question] How paste registers from delete actions

Open Daniel-M opened this issue 6 years ago • 10 comments

Hello, I'm having a hard time using the x register. Whenever I cut something with x, and then try to paste with p/P --each mapped as suggested nmap p <plug>(YoinkPaste_p)-- I don't get the cutted text pasted. I have to swap along the yanks. Is it there a way yo make the cuts to be stored in the first register that Yoink uses when pasting?

Thanks in advance

Daniel-M avatar Oct 09 '19 19:10 Daniel-M

Have you tried enabling g:yoinkIncludeDeleteOperations?

svermeulen avatar Oct 10 '19 03:10 svermeulen

Yes, the overall plugin configuration I'm using is,

let g:yoinkSavePersistently = 1 "" Use the SHAred DAta (SHADA) of nvim
let g:yoinkMaxItems = 20
let g:yoinkSyncNumberedRegisters = 1
let g:yoinkIncludeDeleteOperations = 1

nmap <A-p> <plug>(YoinkPostPasteSwapBack)
nmap <A-n> <plug>(YoinkPostPasteSwapForward)

nmap p <plug>(YoinkPaste_p)
nmap P <plug>(YoinkPaste_P)

Daniel-M avatar Oct 10 '19 15:10 Daniel-M

I can't reproduce it

Here's my full neovim init.vim:


call plug#begin('~/.vim/plugged')

Plug 'svermeulen/vim-yoink'

call plug#end()

let g:yoinkSavePersistently = 1 "" Use the SHAred DAta (SHADA) of nvim
let g:yoinkMaxItems = 20
let g:yoinkSyncNumberedRegisters = 1
let g:yoinkIncludeDeleteOperations = 1

nmap <c-p> <plug>(YoinkPostPasteSwapBack)
nmap <c-n> <plug>(YoinkPostPasteSwapForward)

nmap p <plug>(YoinkPaste_p)
nmap P <plug>(YoinkPaste_P)

Using MacOs, neovim 0.4.2

svermeulen avatar Oct 10 '19 23:10 svermeulen

With that, if I delete a bunch of characters using x then they can be toggled to using <c-n> / <c-p> and also show up in the :Yanks popup. Maybe it's a conflict with another plugin?

svermeulen avatar Oct 10 '19 23:10 svermeulen

With that, if I delete a bunch of characters using x then they can be toggled to using <c-n> / <c-p> and also show up in the :Yanks popup. Maybe it's a conflict with another plugin?

Is swapping yanks the intended behaviour? all I'm trying to do is being able to p right after using x without needing to c-p each time I x something. Thats really my question

Daniel-M avatar Oct 10 '19 23:10 Daniel-M

Oh sorry I misread your question. But it still works how you describe when I test it. Given the text bar and with cursor on the a, hitting xp transforms it to bra

svermeulen avatar Oct 11 '19 02:10 svermeulen

The behaviour actually happens when I'm cutting more than a single character,

vimO

Alt + p is my key mapping to swap between Yanks

Daniel-M avatar Oct 11 '19 05:10 Daniel-M

Ok I have reproduced it now

I noticed that it seems to stop happening when I add set clipboard=unnamed or set clipboard=unnamedplus

Another thing I noticed is that if you execute vwwx then execute :reg<cr> you'll see that the word replaces the default register " like you would expect. When you execute Vx though, the " is unchanged. It seems like this behaviour is part of the problem. I don't really understand why vim behaves differently for V

svermeulen avatar Oct 11 '19 06:10 svermeulen

It might be related to this: https://github.com/neovim/neovim/issues/11202

svermeulen avatar Oct 11 '19 06:10 svermeulen

It might be related to this: neovim/neovim#11202

I don't think it is because it's supposed to be fixed, but I still have the issue with nightly NVIM v0.5.0-dev+1314-g7b0edaac5 when I don't use unnamed or unnamedplus.

If I yank a paragraph normally, it gets in my :Yanks history AND " register as expected: image image (Note that somehow :Yanks is showing me some garbage but this is not causing any trouble)

Then, if I try my cut operation, again :Yanks is properly updated: image But this time, the " register is not updated properly: image And I still have the previous value.

And now, if I try to cut yet something else… image " register holds the previous cut so I can actually paste the content of my previous cut after I cut something else. image

My full config is here. Relevant parts:

let g:yoinkSyncNumberedRegisters = 1
let g:yoinkSavePersistently = 1
let g:yoinkSyncSystemClipboardOnFocus = 1
let g:yoinkIncludeDeleteOperations = 1

nmap <c-n> <Plug>(YoinkPostPasteSwapBack)
nmap <c-p> <Plug>(YoinkPostPasteSwapForward)

nmap p <Plug>(YoinkPaste_p)
nmap P <Plug>(YoinkPaste_P)
nmap gp <Plug>(YoinkPaste_gp)
nmap gP <Plug>(YoinkPaste_gP)

" do not yank on delete operations
nnoremap d "_d
vnoremap d "_d
nnoremap h "_c
vnoremap h "_c

" cut operation
nnoremap <leader><leader>d d
vnoremap <leader><leader>d d
nnoremap <leader><leader>h c
vnoremap <leader><leader>h c

CBenoit avatar May 10 '21 15:05 CBenoit