betabug... Sascha Welter

home english | home deutsch | Site Map | Sascha | Kontakt | Pro | Weblog | Wiki

08 January 2006

vim, Greek, and utf-8 Keyboard Commands

More progress, getting it to work with utf-8

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

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

Posted by betabug at 12:41 | Comments (5) | Trackbacks (1)
ch athens
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
Recent Entries
Best of
Some of the most sought after posts, judging from access logs and search engine queries.

Apple & Macintosh:
Security & Privacy:
Misc technical:
Athens for tourists and visitors:
Life in general:
<< Spirited Platforms for Running Zope | Main | Shakin' Athens >>
Re: vim, Greek, and utf-8 Keyboard Commands

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.

Posted by: betabug at March 29,2009 18:59
Re: vim, Greek, and utf-8 Keyboard Commands

Sehr geehrter Herr Welter!,
Ευχαριστώ πολύ για την σειρά των άρθρων σας πάνω στην χρήση του vim με ελληνικά· λειτουργεί άψογα με την διανομή Ουμπούντου του λίνουξ, έκδοση Χάρντυ, στο παλιό μου Θίνκπαντ.


Posted by: Θ at June 24,2009 04:47
vim commands

Ευχαριστώ κι εγώ για το άρθρο.. Πολύ χρήσιμο!

Αναρωτιόμουν εαν μπορεί κανείς να κάνει ένα alias σε εντολές όπως "w, wq, e" σε ελληνικούς χαρακτήρες. Πχ θα ήταν ωραίο να μπορούσα να χρησιμοποιήσω
:γ για :w
:κ για :q
:γκ για :wq
:ε για :e

και ούτω καθ'εξής

Δεν ξέρω αν ρωτάω κάτι προφανές, αλλά είμαι καινούριος στον vim..
Ευχαριστώ πολύ..

Posted by: Γιώργος at December 02,2009 16:59
Re: vim, Greek, and utf-8 Keyboard Commands

Γιώργο, ναι, αυτό γίνεται. Έκανα ένα καινούριο ποστ:
Map ex Commands in vim

Posted by: betabug at December 03,2009 15:16
You can trackback to:
Map ex Commands in vim

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

Read the linking post here: ch-athens at December 03,2009 15:15