I had a hard time trying to get Japanese display and input working in gvim with X11. So here is a list of the stuff I did to get it to work, and some handy referrences. I'm running the Debian distribution of linux, version 2.3 (unstable, "woody"), so expect some differences if you are setting up a different type of distro.
./configure --with-x --enable-multibyte --enable-fontset --enable-xim! Set the default encoding for Kterm *kanjiMode: euc *international: True ! Supposedly optional with X11R6 *inputMethod: kinput2 ! Supposedly optional with X11R6 ! Choose OverTheSpot, OffTheSpot, or Root. (OnTheSpot is not yet supported by vim5.6) *.preeditType: OverTheSpot ! Font for the Vim text area and the menus. Vim.font: -misc-fixed-medium-r-normal--14-* Vim*fontSet: -misc-fixed-medium-r-normal--14-* Vim*fontList: -misc-fixed-medium-r-normal--14-*
% xrdb -merge .Xresources"
or whatever to have your changes take effect.
kinput2 -canna&
export XMODIFIERS="@im=kinput2"&
To localize all your menus and such to Japanese, and any programs
that you start under your window manager, you can also set the following:
export LANG=ja_JP.eucJP
export LINGUAS=ja
Of course, if you're in X just run these in a terminal somewhere. Anything you run from that terminal will then, of course, be set for Japanese.
Setting the XMODIFIERS environment variable seems to have no effect
for me, but in the Vim help files they say: export XMODIFIERS="@im=your_input_server_name".
And, in a post on comp.editors, export XMODIFIERS='@im=vje', though I don't know what vje means.
Using @im=kinput2, I get weird behavior with kterm, which will not switch to xim
unless I use the Kanji key.
Update: Sunday November 5, 2000 18:40 PST: Since installing
Xfree86 4.0.1 and the new "locales" Debian package, I can't seem to
get input in Vim working without setting this variable. Also,
starting kterm with the -xim switch no longer works.
if $LANG =~ "ja_JP.*" || $TERM == "kterm" || $TERM == "kon"
set fe=japan
endif
This will also setup Vim to display Japanese text in Kon as well,
though I have yet to figure out input in kon.
kterm. Before installing Xfree 4.0.1,
without using the -xim argument, I was not able
to begin Kanji input/conversion with shift-space, only
ctrl-Kanji seems to work. Also, Vim would not handle
the input from the canna server if the -xim option was
not used.
Now, I cannot use the -xim option at all, but at
least ctrl-Kanji still works, both in kterm and in Vim run
from kterm. ^_^
I have also seen rxvt used, but I have not experimented with this.
Try kon at the linux console.
"Setup vim for japanese encoding if the language is japanese
if $LANG =~ "ja_JP.*"
set fileencoding=japan
set guifontset=-misc-fixed-medium-r-normal--14-*
set columns=142 lines=58
else
set guifont=-ttf-lucida\ console-medium-r-normal-*-*-90-*-*-m-*-iso8859-1,Courier_New:h7:w5,Lucida_Console:h9:w5,6x10
set columns=142 lines=66
endif
The important parts, of course, are setting the fileencoding and the guifontset.
Note: do not set guifont if you want to display Japanese. Make sure it is not set in any of your other startup files.
#!/bin/bash # Check if the input server is running; run it if not. ps u -C kinput2 |grep $USER > /dev/null || kinput2 -canna& # set LANG to the locale of your choice, though sjis and jis may not work well with vim. LANG=ja_JP.eucJP gvim $@
Alternatively, you could just set this on the command line before
running gvim, with something like:
% LANG=ja_JP.eucJP; gvim
% kvim).
If you have your LANG environment variable set already, just start gvim:
% vim -g.
Press Shift-Space or ctrl-Kanji to begin input conversion.
You can map a key to the keysym "Kanji" in your xkb map or your xmodmap. I prefer the xkb extensions of X11R6 because it loads keymaps (even uncompiled ones) infinately many times faster than xmodmap.
[[ "$TERM" == "kterm" ]] && export LANG=ja_JP.eucJP
:let $LANG="ja_JP.eucJP" | gui
Steven Mueller, diffusor@ugcs.caltech.edu