how to insert specific yanks?
acornejo opened this issue · 4 comments
suppose i look at my yank history using :Yanks
and realize i want to insert yank number 13.
is there a command ot APi to get this? for instance :Paste 13
, or am I supposed to just paste and then press c-n 13 times?
if this doesn't exist it would be a great additiom to this already fantastic plugin. ideally we get both a commamd to do it, and also a function to access each element in the yank history by number. if this functionality already exists then it would be useful to document it im the readme or help.
i see at least two open issues about making the Yanks screen interactive. the feature described here is easier to implement, and would allow folks to hook up easyclip with unite, fzf, selecta, or any one of the many other vim pluggins that provide completion/selection functionality... which IMHO is a much better alternative than to build a separete interactivity model into easyclip
Glad you're enjoying the plugin!
No, a command like that doesn't exist, but this would be trivial to add. I can see what you mean, so I'll take a look at adding this later today.
thank you!
Ok I added a command Paste
. Paste 0
is equivalent to p
, Paste 1
is equivalent to "1p
, etc.
Also added methods EasyClip#PasteIndex(index)
and EasyClip#GetYankAtIndex(index)
Thank you!
I've tested it and works great. Here is the FZF integration bit (in case you are interested in trying it yourself). Similar things could be done for Unite, ctrl-p and others.
function! s:yank_list()
redir => ys
silent Yanks
redir END
return split(ys, '\n')[1:]
endfunction
function! s:yank_handler(reg)
if empty(a:reg)
echo "aborted register paste"
else
let token = split(a:reg, ' ')
execute 'Paste' . token[0]
endif
endfunction
command! FZFYank call fzf#run({
\ 'source': <sid>yank_list(),
\ 'sink': function('<sid>yank_handler'),
\ 'options': '-m',
\ 'down': 12
\ })