我需要在Vim中重新映射 C-x ,就像在某些Windows编辑器中一样:
答案 0 :(得分:2)
" Source distribution script in $VIMRUNTIME directory
:runtime mswin.vim
if has('clipboard')
nmap <silent> <C-X> :call CutNonEmptyLineToClipboard()<CR>
" If the current line is non-empty cut it to the clipboard.
" Else do nothing.
function! CutNonEmptyLineToClipboard()
if strlen(getline('.')) != 0
normal 0"*D
endif
endfunction
endif
以下更新版本。不得不谷歌“黑洞注册”,我不知道。 (谢谢!)我还放了一个不同的空行匹配器。选择最适合你的版本。
if has('clipboard')
nmap <silent> <C-X> :call CutNonEmptyLineToClipboard()<CR>
" If the current line is non-empty cut it out into the clipboard.
" Else delete it into the black hole register (named _).
function! CutNonEmptyLineToClipboard()
" Test if the current line is non-empty
" if strlen(getline('.')) != 0
if match(getline('.'), '^\s*$') == -1
normal 0"*D
else
normal "_dd
endif
endfunction
endif