personal web log written by izabeera and dryobates

vim kanji ibus japanese

Kanji in Vim

by dryobates

If you are Vim user and you need to type some japanese signs into your documents from time to time then read this and see how simple it can be done.

From time to time I input new kanji symbols into OpenOffice document and when there is whole new page I print it to have some quick reference when I forgot some of them.

Until today I did it in a manner which is shameful for vim user. It is even shameful for unix user ;) I was staring Windows, run OpenOffice, change keyboard layout and input kanji symbols. Enough!

Today, when I was going to write some new part of kanji I recalled that some time ago I had installed SCIM [1]. It allowed to input kanji in X. Quick googling showed that SCIM still exists but there’s also new player: IBus [2]. I wouldn’t be myself if I won’t give it a try.

I have installed it like from FreeBSD ports:

$ portmaster japanese/ibus-anthy

In order to enable ibus we need start it at the begining of our X session. I have added it to my .xinitrc:

export XIM=ibus
export GTK_IM_MODULE=ibus
export QT_IM_MODULE=xim
export XMODIFIERS=@im=ibus
export XIM_PROGRAM="ibus-daemon"
export XIM_ARGS="--daemonize --xim"

After restart of my window manager (awesome) on my systray appeared ibus icon (keyboard with globe). Right click on it, then select Preferences -> Input method -> Japanese -> Anthy. Click Add and Close. By pressing Ctrl-Space I can switch input methods and input kanji 日本語.

But it doesn’t work in console programs... Yet. If you use urxvt [3] as your terminal as I do then you are lucky. Into your .Xdefaults/.Xresources file add:

URxvt.inputMethod: ibus
URxvt.preeditType: OverTheSpot

Now in vim or Mutt running in urxvt you can input kanji with ease.

[1]Smart Common Input Method - input framework method for unix:
[2]Intelligent Input Bus - input framework method for unix:
[3]rxvt-unicode - terminal emulator with unicode support:
Jakub Stolarski. Software engineer. I work professionally as programmer since 2005. Speeding up software development with Test Driven Development, task automation and optimization for performance are things that focus my mind from my early career up to now. If you ask me for my religion: Python, Vim and FreeBSD are my trinity ;) Email: