Skip to content

Instantly share code, notes, and snippets.

@Shougo
Created January 28, 2010 08:15
Show Gist options
  • Save Shougo/288546 to your computer and use it in GitHub Desktop.
Save Shougo/288546 to your computer and use it in GitHub Desktop.
" 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