Skip to content

Instantly share code, notes, and snippets.

@jeetsukumaran
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeetsukumaran/10015995 to your computer and use it in GitHub Desktop.
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
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