config/.vim/plugin/keymap.vim

38 lines
1.4 KiB
VimL
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

" See https://vim.fandom.com/wiki/Mapping_fast_keycodes_in_terminal_Vim
" See termcap-options for mapped key info
" Some may not mapped correctly mapped for F1 to F4 (See vt100-function-keys )
" To set them, you can have a look at https://vim.fandom.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_2)
" :set <S-F1>=<press Ctrl-V> <press S-F1><press esc>
" Those are the key for gnome-terminal with zsh on archlinux
if &term =~ "xterm."
set <S-F1>=
set <S-F2>=
set <S-F3>=
set <S-F4>=
endif
"you could also direclty map them
" map <press ctrl-V><press your key map> :some vimcmds <press Ctrl-V><press
" enter>
" you can check the result with :map <press ctrl-V><press your key map>
" MapFastKeycode: helper for fast keycode mappings
" makes use of unused vim keycodes <[S-]F15> to <[S-]F37>
function! <SID>MapFastKeycode(key, keycode)
if s:fast_i == 46
echohl WarningMsg
echomsg "Unable to map ".a:key.": out of spare keycodes"
echohl None
return
endif
let vkeycode = '<'.(s:fast_i/23==0 ? '' : 'S-').'F'.(15+s:fast_i%23).'>'
exec 'set '.vkeycode.'='.a:keycode
exec 'map '.vkeycode.' '.a:key
let s:fast_i += 1
endfunction
let s:fast_i = 0
call <SID>MapFastKeycode('<C-F1>', "")
call <SID>MapFastKeycode('<C-F2>', "")
call <SID>MapFastKeycode('<C-F3>', "")
call <SID>MapFastKeycode('<C-F4>', "")