Thanks for your answer, I learned a lot about the imactivatekey option. Unfortunately I work mainly on terminal vim and all my attempts with this option failed.
At the end I investigated how to manipulate IBus via DBUS and wrote a vim plugin to do the dirty work. This plugin disables IM when leaving insert mode and re-enables it when entering insert mode: https://github.com/hsanson/vim-im This plugin currently works on my desktop: Ubuntu 12.04 with KDE4 using IBus with Anthy for Japanese input. I have no plans to test other configurations but pull requests are welcome. Horacio On Saturday, January 18, 2014 11:28:38 PM UTC+9, Yukihiro Nakadaira wrote: > On Fri, Jan 17, 2014 at 10:54 PM, Horacio Sanson <[email protected]> wrote: > > Japanese keyboards have a Kana key that allows me to easily switch between > Japanese and English input. > > > > > Is very common for me during insert mode to press the Kana key to input some > Japanese text after which I press esc to go back to normal mode. > > > > > > The problem is that after entering normal mode the input method is still in > Japanese and it is totally useless in vim normal mode. It is impossible to > input any command with the Japanese input and since I get no feedback it > takes some seconds before I realize why everything I type seems to do nothing > in vim. > > > > > I would like to make a mapping so when I exit insert mode (or enter normal > mode) the input method is always reset back to English. Unfortunately I am > unable to find how to map this key. > > > > Bonus points if I can make remember the last input method used in insert mode > and restore it when entering insert mode again. > > > > Other, possibly better solution, is to find out how to change the input > method via command line and make a autocmd that executes the command when > entering normal mode. Unfortunately I still cannot find a way to manipulate > the input method from the command line. BTW: I use Linux (Kubuntu) with ibus > as input method manager. > > > > If you are using GUI version of vim, you can use 'imactivatefunc' and > 'imstatusfunc' option to control Input Method. > > For ibus, you can try > https://github.com/koron/imcsc-vim/tree/master/ibus-python. > > This is a plugin to control ibus using these options. This requires > if_python feature. But unfortunately latest ibus removes some API > required by this plugin. So perhaps it may not work in your PC. > > To just inactivate Input Method, you can use InsertLeave event. Open > > Input Method settings dialog and set shortcut key to set off Input > Method. Then, send the key in InsertLeave event. > For example, if shortcut key is ctrl-shift-j: > :autocmd InsertLeave * call system('xvkbd -text "\[Control]J"') > > > -- > Yukihiro Nakadaira - [email protected] -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
