From 0c14a119b3f3afff9d7d9dc984fcaad95ef204db Mon Sep 17 00:00:00 2001 From: yazgoo Date: Sat, 28 Aug 2021 21:26:34 +0200 Subject: [PATCH] add YankHistoryYank --- doc/yank-history.txt | 3 +++ plugin/yank-history.vim | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/yank-history.txt b/doc/yank-history.txt index 34a1bcb..2ad6db6 100644 --- a/doc/yank-history.txt +++ b/doc/yank-history.txt @@ -28,6 +28,9 @@ COMMANDS *yank-history-commands* :YankHistoryPaste[!] *:YankHistoryPaste* opens FZF to select yank history file to be pasted +:YankHistoryYank[!] *:YankHistoryYank* + opens FZF to select yank history file to be added to the yank register + :YankHistoryRg[!] *:YankHistoryRg* grep within yank history via FZF and opens the file matching the search pattern diff --git a/plugin/yank-history.vim b/plugin/yank-history.vim index 86a96e2..58c5384 100644 --- a/plugin/yank-history.vim +++ b/plugin/yank-history.vim @@ -34,7 +34,7 @@ function! YankHistoryYank() call mkdir(g:yank_history_tmp_dir, "p", 0700) let tmp = g:yank_history_tmp_dir . '/' . strftime("%d-%m-%y-%H-%M-%S.").&filetype call writefile(split(@0, "\n", 1), tmp, 'b') - let md5=trim(system('md5sum ' . tmp . ' | cut "-d " -f1')) + let md5=trim(system('md5sum ' . tmp . ' | cut "-d " -f1')) let out = g:yank_history_dir.'/'.md5.'.'.&filetype if filereadable(out) silent execute "!rm " . tmp @@ -77,6 +77,19 @@ command! -bang -nargs=0 YankHistoryPaste \ 0 \ ) +"" +" opens FZF to select yank history file to be +" added to the yank register +command! -bang -nargs=0 YankHistoryYank + \ call fzf#vim#grep( + \ 'ls -t ' . g:yank_history_dir . '/*', 0, + \ { + \ 'options': ["--prompt", "> ", "--preview", s:yank_history_script_dir .'/../../fzf.vim/bin/preview.sh {}'], + \ 'sink': function('s:yank_history_yank') + \ }, + \ 0 + \ ) + "" " grep within yank history via FZF and opens the file matching the search " pattern