OK, this took several days of struggle against the skk.vim
plugin mentioned by @SatoKatsura. All the documentation is in Japanese therefore I still do not know of most of its features, and, certainly, there are better ways to accomplish SKK conversion ("Henkan" in Japanese) in Vim than the one presented here. Yet, it works well enough to be comparable to emacs
' SKK mode.
First of all you need to donwload the SKK dictionary. Any of them would be enough but I suggests the large dictionary for the sake of completeness. The dictionary comes in the EUC-JP
encoding, therefore we need to convert it:
gunzip SKK-JISYO.L.gz
iconv -f euc-jp -t utf-8 SKK-JISYO.L > skk-jisyo-utf-8.l
If your Vim has the +iconv
feature the iconv
utility should be available on your machine.
The SKK dictionary is in the correct format to be used as a thesaurus, therefore we will set that in Vim and use <c-x><c-t>
to perform thesaurus completion. Every line in the SKK dictionary looks as follows:
<kana entry> / <kanji entry> / <kanji entry> / ...
わきでy / 湧き出 / 涌き出 /
Now, we only need to write the <kana entry>
part and Vim will be capable of completing the rest for us.
skk.vim
can write in Kana in insert-mode. It can write in both Hiragana and Katakana but the SKK dictionary has entries in Hiragana only. Therefore we add a Toogle function wrapper around skk.vim
to use either Hiragana or Katakana when in insert-mode. When we want SKK completion we must be in Hiragana mode (this is analogous to emacs
's SKK mode).
Here is what I wrote in my .vimrc
to wrap skk.vim
and use the SKK dictionary as a thesaurus:
let g:skk_initial_mode = 'hira'
let g:skk_script = '~/vim/skk/skk.vim'
set completeopt=menuone,preview
set thesaurus=~/vim/skk/skk-jisyo-utf-8.l
function! ToogleMode()
if 'hira' ==# g:skk_initial_mode
let g:skk_initial_mode = 'kata'
else
let g:skk_initial_mode = 'hira'
endif
execute "source " . g:skk_script
endfunction
To enter Kana mode you press <c-j>
to complete a Kanji you need to press <c-j>
to exit Kana mode and then <c-x><c-t>
to bring up thesaurus completion.
And here is how it looks (the text is exactly the same as in the question):
Disadvantages and quirks:
Since we are using Vim's thesaurus we need to add spaces between words. This is not needed in emacs
's SKK becuase it keeps a selection trailing behind (see the screenshot in the question).
This code is terribly hacky, I just cannot understand about 70% of skk.vim
because I'm unable to read the documentation. There certainly are better ways to perform this.
You need to exit the Kana mode to perform the thesaurus completion, in Kana mode <c-x><c-t>
does not work as expected.