Created
January 28, 2010 08:15
-
-
Save Shougo/288546 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Sticky shift in English keyboard."{{{ | |
" Sticky key. | |
inoremap <expr> ; <SID>sticky_func() | |
cnoremap <expr> ; <SID>sticky_func() | |
snoremap <expr> ; <SID>sticky_func() | |
function! s:sticky_func() | |
let l:sticky_table = { | |
\',' : '<', '.' : '>', '/' : '?', | |
\'1' : '!', '2' : '@', '3' : '#', '4' : '$', '5' : '%', | |
\'6' : '^', '7' : '&', '8' : '*', '9' : '(', '0' : ')', '-' : '_', '=' : '+', | |
\';' : ':', '[' : '{', ']' : '}', '`' : '~', "'" : "\"", '\' : '|', | |
\} | |
let l:special_table = { | |
\"\<ESC>" : "\<ESC>", "\<Space>" : ';', "\<CR>" : ";\<CR>" | |
\} | |
if mode() !~# '^c' | |
echo 'Input sticky key: ' | |
endif | |
let l:key = getchar() | |
if nr2char(l:key) =~ '\l' | |
return toupper(nr2char(l:key)) | |
elseif has_key(l:sticky_table, nr2char(l:key)) | |
return l:sticky_table[nr2char(l:key)] | |
elseif has_key(l:special_table, nr2char(l:key)) | |
return l:special_table[nr2char(l:key)] | |
else | |
return '' | |
endif | |
endfunction | |
"}}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment