maxbrunsfeld / vim-yankstack

A lightweight implementation of emacs's kill-ring for vim
437 stars 29 forks source link

How does it work to obtain visual selection buffer? #59

Open unphased opened 7 years ago

unphased commented 7 years ago

I'm trying to write some vimscript to allow me to instantly write the yanked buffer out to my filesystem, so that I can make more tools around it. (mainly so I can be able to slurp the yank into another instance of Vim, when on a headless machine that does not have a clipboard)

Of course, I'd like to keep vim yankstack functionality intact.

Now I also expect that yankstack itself has some code that achieves (using some black magic) the slurping of the buffer.

I've been reading the source code and I'm still a little confused.

My main limiting issue is that I need to cause the original yank behavior to proceed, in particular in visual mode, and to run some code AFTER that happens. This appears to be essentially impossible without manually reimplementing what the y key does because the contents of the yank buffer do not land until after it happens, and in an expr map I have to have the thing return (and therefore any funcs it calls) the "y" value in order for that yank to proceed.

Maybe yankstack works around this by just cleverly shuffling registers, so that the next paste operations work properly. But if I need to persist the yank onto the filesystem then I seem to be out of luck.

unphased commented 7 years ago

I think the existence of this shows that what i've discovered is a real problem.

I do use nvim sometimes, but last I checked had some performance issues with it compared to vanilla vim.