Saturday, January 18, 2014

Re: How to map the Kana key on Japanese keyboards

On Fri, Jan 17, 2014 at 10:54 PM, Horacio Sanson <horacio.sanson@gmail.com> 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 - yukihiro.nakadaira@gmail.com

--
--
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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: