Last active
August 29, 2015 13:58
-
-
Save jeetsukumaran/10015995 to your computer and use it in GitHub Desktop.
Smart (`infercase`) Dictionary Completions in Vim Without Otherwise Messing with Your `ignorecase` Settings
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
function! s:_setup_cidictcompletion() | |
let g:_old_ignorecase_state=&ignorecase | |
inoremap <C-X><C-K> <ESC>:let g:_old_ignorecase_state=&ignorecase<CR>:set ignorecase<CR>:set infercase<CR>a<C-X><C-K> | |
" inoremap <expr> <CR> pumvisible() ? "\<C-y><ESC>:set noignorecase<CR>a" : "\<C-g>u\<CR>" | |
" inoremap <expr> <C-J> pumvisible() ? "\<C-y><ESC>:set noignorecase<CR>a" : "\<C-g>u\<C-J>" | |
let restore=' pumvisible() ? "\<C-y><ESC>:let &ignorecase=g:_old_ignorecase_state<CR>' | |
for key in ["<CR>", "<C-J>", "<C-Y>"] | |
execute "inoremap <expr> " . key . restore . 'a" : "\<C-g>u\<CR>"' | |
endfor | |
for key in ["<ESC>", "<C-C>"] | |
execute "inoremap <expr> " . key . restore . '" : "\' . key . '"' | |
endfor | |
endfunction | |
call <SID>_setup_cidictcompletion() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment