As I said in the comments, mappings in are not designed to do what you want to do. An interesting option for this use case is langmap
.
This option allows to keep the behavior or your keyboard in insert mode and change its behavior in the other modes.
To use it Vim has to be compiled with +langmap
, you can check that this option is enabled with echo has('langmap')
: if the command returns 1
the option is enabled else you'll have to get a setup with this option enabled (to know how to do that, it is another question).
When it is enabled, the option takes pairs of characters for example set langmap += à@
will allow you to add a à
in your buffer when you're in insert mode and you type a à
but typing à
in normal mode will actually trigger a @
(this example can be useful on azerty keyboards to ease work with macros).
To use langmap in greek you can follow the example given in :h 'langmap'
adding this line to your vimrc
(Copying this line from here may not be a good idea since I'm really not sure of the encoding, yanking the line directly from the help file is probably safer):
:set langmap=ΑA,ΒB,ΨC,ΔD,ΕE,ΦF,ΓG,ΗH,ΙI,ΞJ,ΚK,ΛL,ΜM,ΝN,ΟO,ΠP,QQ,ΡR,ΣS,ΤT,ΘU,ΩV,WW,ΧX,ΥY,ΖZ,αa,βb,ψc,δd,εe,φf,γg,ηh,ιi,ξj,κk,λl,μm,νn,οo,πp,qq,ρr,σs,τt,θu,ωv,ςw,χx,υy,ζz
Now from what I understand in your comments it remains an issue when you try to use predefined commands: when you type a command, the insert mode behavior will be triggered instead of the langmap defined behavior. Unfortunately I'm not sure I have a good solution for that. One idea could be to redefine commands for example like that:
command λς lw
This way when you'll type the command λς
Vim will execute lw
but I see several drawbacks to this method:
- It might be a huge pain in the butt to redefine all the commands you want to use.
- User-defined commands have to start with a capital letter, and I have now idea how convenient it is to do that in greek.
So maybe a plugin suggested by @Alexander Myshov in his answer to this question could be useful (as I never tried any of these I don't know if they solve the problem but it seems like they do).
langmap
option (see the doc which includes an example for greek layout). This option was actually made to help dealing with non latin keyboards like greek or cyrilic. It allows you to define pairs of symbols which will be interpreted normally in insert mode but will be replaced in other modes, maybe this will help you.:echo has('langmap')
if you get a1
you have it if you get a0
you don't.brew install vim --override-system-vi
and:echo has &c
now returns 1. ZZ works. The problem with\lv
&c remains.:echo has &c
part, I don't see how it is related tolangmap
also once you have vim compiled withlangmap
you have to specify the mappings with:set langmap=ΑA,ΒB,ΨC [...]
in your vimrc.