vim, Greek, and utf-8 Keyboard Commands
Trying something I wanted to play around with for a long time, I made more progress in setting up vim to work with Greek. As seen in the previous posts about this topic there are some prerequisites to get this working (especially on Mac OS X). To get keyboard commands work with the greek keyboard too, you can use the map keyboard command, it's a bit more tedious than langmap, but you can put it into your .vimrc and have it always ready. Read on for details...
- You need vim with multilingual capabilities (multibyte support compiled in), as described in State of Greek and UTF-8 in the Mac OS X Terminal and in OS X you will have to set up your Terminal properly.
- If you work with ISO-8859-7 (I don't), you can use the langmap command, as described in Greek in vim with langmap - only ISO-8859-7, on OS X more mucking around with Terminal.app required
- If you prefer to work with modern Unicode UTF-8, as I do, you can use the map command to assign the greek letters in command mode to the latin character that command mode expects.
Let's go in for the details about using map:
The book "Learning the vi Editor" describes the map command as follows:
While you're editing, you may find that you are using a command sequence frequently, or you may occasionally use a very complex command sequence. To save yourself keystrokes, or the time that it takes to remember the sequence, you can assign the sequence to an unused key by using the map command.
The map command acts a lot like ab except that you define a macro for vi's command mode instead of for insert mode.
So we can use the map command to define ξ to act like j, moving the cursor down one line. We will therefore just define one map command for each character we need. This would be tedious to do each time we need to edit a greek file. That's why we put it into our .vimrc file and then we are ready to use it anytime. Here is the part of my .vimrc file as far as editing for Greek is concerned:
" greek stuff: " always edit in utf-8: set encoding=utf-8 " but be ready to change encoding with a couple of shortcuts: map _u :set encoding=utf-8 map _1 :set encoding=iso-8859-1 map _7 :set encoding=iso-8859-7 " assign keyboard commands while using the greek keyboard: map Α A map Β B map Ψ C map Δ D map Ε E map Φ F map Γ G map Η H map Ι I map Ξ J map Κ K map Λ L map Μ M map Ν N map Ο O map Π P map Q Q map Ρ R map Σ S map Τ T map Θ U map Ω V map W W map Χ X map Υ Y map Ζ Z map α a map β b map ψ c map δ d map ε e map φ f map γ g map η h map ι i map ξ j map κ k map λ l map μ m map ν n map ο o map π p map q q map ρ r map σ s map τ t map θ u map ω v map ς w map χ x map υ y map ζ z
For this to work, we have to be sure to be using utf-8 encoding while editing the .vimrc file itself. I believe you can use this in parallel with langmap if you want to edit ISO-8859-7 and UTF-8 files.
Now my next target will be to get spellchecking too, since my spelling in Greek is pretty bad :-).