mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-13 13:48:00 +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
|
function! SpaceVim#default#keyBindings() abort
|
||||||
call SpaceVim#logger#debug('init default key bindings.')
|
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')
|
||||||
nnoremap <expr> <Leader>P clipboard#paste('P')
|
nnoremap <expr> <Leader>P clipboard#paste('P')
|
||||||
xnoremap <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
|
" yank to system clipboard
|
||||||
function! clipboard#yank() abort
|
function! clipboard#yank() abort
|
||||||
call system(s:yank_cmd, s:get_selection_text())
|
call system(s:yank_cmd, s:get_selection_text())
|
||||||
return ''
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
@ -65,11 +64,16 @@ endfunction
|
|||||||
|
|
||||||
|
|
||||||
function! s:get_selection_text()
|
function! s:get_selection_text()
|
||||||
let save_x = @x
|
let [begin, end] = [getpos("'<"), getpos("'>")]
|
||||||
normal gv"xy
|
let lastchar = matchstr(getline(end[1])[end[2]-1 :], '.')
|
||||||
let result = @x
|
if begin[1] ==# end[1]
|
||||||
let @x = save_x
|
let lines = [getline(begin[1])[begin[2]-1 : end[2]-2]]
|
||||||
return result
|
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
|
endfunction
|
||||||
|
|
||||||
let [s:yank_cmd, s:paste_cmd] = s:set_command()
|
let [s:yank_cmd, s:paste_cmd] = s:set_command()
|
||||||
|
Loading…
Reference in New Issue
Block a user