mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-02 20:30:05 +08:00
fix(clipboard): fix leader y
key binding
This commit is contained in:
parent
79378b0e4c
commit
f89a83ece8
@ -161,7 +161,7 @@ endfunction
|
||||
|
||||
function! SpaceVim#default#keyBindings() abort
|
||||
call SpaceVim#logger#debug('init default key bindings.')
|
||||
xnoremap <expr> <Leader>y clipboard#yank()
|
||||
xnoremap <silent> <Leader>y :<C-u>call clipboard#yank()<cr>
|
||||
nnoremap <expr> <Leader>p clipboard#paste('p')
|
||||
nnoremap <expr> <Leader>P clipboard#paste('P')
|
||||
xnoremap <expr> <Leader>p clipboard#paste('p')
|
||||
|
16
bundle/vim-clipboard/autoload/clipboard.vim
vendored
16
bundle/vim-clipboard/autoload/clipboard.vim
vendored
@ -52,7 +52,6 @@ endfunction
|
||||
" yank to system clipboard
|
||||
function! clipboard#yank() abort
|
||||
call system(s:yank_cmd, s:get_selection_text())
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
|
||||
@ -65,11 +64,16 @@ endfunction
|
||||
|
||||
|
||||
function! s:get_selection_text()
|
||||
let save_x = @x
|
||||
normal gv"xy
|
||||
let result = @x
|
||||
let @x = save_x
|
||||
return result
|
||||
let [begin, end] = [getpos("'<"), getpos("'>")]
|
||||
let lastchar = matchstr(getline(end[1])[end[2]-1 :], '.')
|
||||
if begin[1] ==# end[1]
|
||||
let lines = [getline(begin[1])[begin[2]-1 : end[2]-2]]
|
||||
else
|
||||
let lines = [getline(begin[1])[begin[2]-1 :]]
|
||||
\ + (end[1] - begin[1] <# 2 ? [] : getline(begin[1]+1, end[1]-1))
|
||||
\ + [getline(end[1])[: end[2]-2]]
|
||||
endif
|
||||
return join(lines, "\n") . lastchar . (visualmode() ==# 'V' ? "\n" : '')
|
||||
endfunction
|
||||
|
||||
let [s:yank_cmd, s:paste_cmd] = s:set_command()
|
||||
|
Loading…
Reference in New Issue
Block a user