Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How paste registers from delete actions #14

Open
Daniel-M opened this issue Oct 9, 2019 · 10 comments
Open

[Question] How paste registers from delete actions #14

Daniel-M opened this issue Oct 9, 2019 · 10 comments

Comments

@Daniel-M
Copy link

Daniel-M commented Oct 9, 2019

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

@svermeulen
Copy link
Owner

Have you tried enabling g:yoinkIncludeDeleteOperations?

@Daniel-M
Copy link
Author

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)

@svermeulen
Copy link
Owner

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
Copy link
Owner

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?

@Daniel-M
Copy link
Author

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

@svermeulen
Copy link
Owner

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

@Daniel-M
Copy link
Author

Daniel-M commented Oct 11, 2019

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

vimO

Alt + p is my key mapping to swap between Yanks

@svermeulen
Copy link
Owner

svermeulen commented Oct 11, 2019

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
Copy link
Owner

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

@CBenoit
Copy link

CBenoit commented May 10, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants