From 77823ecd4fe8372af5ed4a533ffc85159e106b05 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Fri, 1 Dec 2017 14:05:46 +0800 Subject: [PATCH] Add feature for copy/paste file --- config/plugins/vimfiler.vim | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/config/plugins/vimfiler.vim b/config/plugins/vimfiler.vim index 9bfdd8a21..4473c0e2e 100644 --- a/config/plugins/vimfiler.vim +++ b/config/plugins/vimfiler.vim @@ -1,4 +1,7 @@ scriptencoding utf-8 + +let s:VCOP = SpaceVim#api#import('vim#compatible') + let g:vimfiler_as_default_explorer = get(g:, 'vimfiler_as_default_explorer', 1) let g:vimfiler_restore_alternate_file = get(g:, 'vimfiler_restore_alternate_file', 1) let g:vimfiler_tree_indentation = get(g:, 'vimfiler_tree_indentation', 1) @@ -80,6 +83,7 @@ function! s:vimfilerinit() nnoremap sg vimfiler#do_action('vsplit') nnoremap sv vimfiler#do_action('split') nnoremap st vimfiler#do_action('tabswitch') + nnoremap yY :call copy_to_system_clipboard() nmap gx (vimfiler_execute_vimfiler_associated) nmap ' (vimfiler_toggle_mark_current_line) nmap v (vimfiler_quick_look) @@ -92,4 +96,20 @@ function! s:vimfilerinit() nmap (vimfiler_smart_l) endf +function! s:copy_to_system_clipboard() abort + let filename = vimfiler#get_marked_filenames(b:vimfiler) + + if empty(filename) + " Use cursor filename. + let filename = vimfiler#get_filename() + if filename == '..' || empty(vimfiler#get_file(b:vimfiler)) + let filename = b:vimfiler.current_dir + else + let filename = vimfiler#get_file(b:vimfiler).action__path + endif + endif + " we need xclip-copyfile + call s:VCOP.systemlist(['xclip-copyfile', filename]) +endfunction + " vim:set et sw=2: