Greek in vim with langmap - only ISO-8859-7
In a comment to my old post about State of Greek and UTF-8 in the Mac OS X Terminal Andreas Triantafillidis asks if I finally managed to use vim with Greek. Answer: The state is still somehow the same. Using a vim with multilingual capabilities compiled in, I can read and write in Greek, but not as good as I want, because mapping of keyboard commands does not work with Unicode, but read on for what I got with ISO-8859-7...
Tassos Pavlakos (in another comment to that post) had suggested vim's langmap command, which is the right tool for the job. But typing :help langmap in vim gives us the following information:
This only works for 8-bit characters. The value of 'langmap' may be specified with multi-byte characters (e.g., UTF-8), but only the lower 8 bits of each character will be used.This maps right with my experience. Trying to use the langmap feature with Greek in UTF-8 will leave vim just beeping at you.
So today I tried a small experiment. The Mac OS X Terminal.app does not offer ISO-8859-7 in its list of default encodings (and at least for Mac OS X 10.3 there is no way to change that list through the GUI). So I tweaked the rules a bit to see if I could get it to work, here are the steps I took:
- I opened a Terminal window, set it up the way I like and saved it with the File -> Save As... command.
- opened the resulting .term file with vim
- Searched for "encoding" through the pseudo-XML gets me the <Key>StringEncoding</Key> line, and on the next line I have <String>4</String>
- Now, the 4 is for Unicode UTF-8, and I went to change this line to <Integer>-2147483129</Integer> which represents ISO-8859-7 in Apple's way of thinking.
- Opened the changed file and hit Apple-I for the "Terminal Inspector" gives me an empty entry in the "Character Set Encoding" list (and once I switched to one of the other encodings, no way back), but playing a bit around shows, that I have indeed greek iso encoding running.
- Now I opened vim in that window, did a :set encoding=iso-8859-7 and then a :set langmap=ξj,κk and I was able to move up and down the lines in my file while I was on the greek keyboard. Just to mention that too, I was using the "Greek" UTF-8 keyboard that comes with my plain vanilla OS X, no XGreek keyboard or Rainblow patch system. From what I remember, with the Rainbow patch you get ISO-8859-7 as a choice in Terminal.app.
So, what does that show us? With a bit of quirky hacking and the right version / compilation settings of vim, we can read and write unhindered in Greek, as long as it's ISO-8859-7 Greek. Which is kind of funny, since vim claims to be UTF-8 internally. But I guess that's just the way the langmap command and it's underlying architecture are implemented. If the terminal software you use supports ISO-8859-7 it's not even that difficult to try it out (I don't know about Linux/BSD terminal apps, my trials are on the Mac). I don't think I will like it though, since I believe the time for the ISO encodings is over, I became a Unicode believer. Last remark: This is vim 6.1, once I'm back on the net I will check out if anything has changed in newer versions.