Skip to content

Instantly share code, notes, and snippets.

@dahu
Created March 14, 2015 00:58
Show Gist options
  • Select an option

  • Save dahu/bb62ea4bc8b64efd709f to your computer and use it in GitHub Desktop.

Select an option

Save dahu/bb62ea4bc8b64efd709f to your computer and use it in GitHub Desktop.
Automatically enable ibus IME when entering insert mode
" Barry Arthur, March 2015
" Auto-toggle IME when in insert mode
" leaving it "off" in normal mode.
"
" Set your ibus_normal and ibus_insert mode engines in your ~/.vimrc
" In insert mode, use the <LShift> key to toggle between compose and
" passthrough modes. Set your IBus preferences as to which mode you
" start in.
if !exists('ibus_normal')
let ibus_normal = 'xkb:us::eng'
endif
if !exists('ibus_insert')
let ibus_insert = 'pinyin'
endif
augroup IBus
au InsertEnter * :call system('ibus engine ' . g:ibus_insert)
au InsertLeave * :call system('ibus engine ' . g:ibus_normal)
augroup END
function! IBusEngine()
return split(system('ibus engine'), "\n")[0]
endfunction
let &statusline = '%f%m%r%h%w [%n:%{&ff}/%Y] %{IBusEngine()}%=[0x%04.4B][%03v][%p%% line %l of %L]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment