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...

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:

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 :-).

Life in Athens (Greece) for a foreigner from the other side of the mountains.
And with an interest in digital life and the feeling of change in a big city.
Multilingual English - German - Greek.Main blog page

Hi,
langmap works fine with utf8 but doesn't work in command mode. Neither does this way though. It works for move commanda etc but not in command mode. After the : it's all greek characters again.

Posted by:
Tree
at March 25,2009 22:14

Re: vim, Greek, and utf-8 Keyboard Commands

Of course it's greek characters after the ":" !! How else do you think would you enter something like :s/ένα/δυο if you hacked in something that switched Greek characters to latin characters at the ex prompt?

Yes, you will have to switch keyboards there, sometimes a lot. But you have to tell the computer what character you want to type, there's no help for that.

Doing the "map" thing for command mode makes sense, because there are no commands that are called with Greek characters. But on the prompt you enter more than just commands.

In vim, Greek, and utf-8 Keyboard Commands, Giorgos had asked in a comment if it would be
possible to not only switch vi's keyboard shortcuts to a Greek keyboard, but also to use Greek
letters for ex commands. For example to be able to write :γ for :...