This problem can be solved using Vim's keymap
option. It allows to define alternate keymap to use in insert and replace modes. There are many predefined keymaps for some languages, you can browse them all using :e $VIMRUNTIME/keymap
in Vim itself.
To switch between default and alternate keymap use Ctrl+^ in insert and replace mode. Regardless of current keymap in insert and replace mode, keymap in normal mode stays default, so you can leave insert mode writing greek and immediately use Vim keybindings without switching layout. And when you return in insert or replace mode (or start search by /
), Vim will switch you to greek keymap automatically. Thus, keymap is remembered between inserts.
I recommend you to add this line to your .vimrc
file:
set keymap=greek_utf-8
(Note that there are several other greek keymaps (which probably differ only by encoding) provided in Vim, so you can choose one that suits your configuration.) With this option set, you should work in Vim using English keyboard layout and switch keymap using Ctrl+^ and not your system-wide layout switch.
I also recommend setting these:
set iminsert=0
set imsearch=-1
See :help iminsert
and :help imsearch
to ensure that it does not contradict with your configuration.
There is also langmap
mode, which was introduced in Vim earlier than keymap
, as far as I know, and allows to achieve somewhat like keymap by manual specifying letter pairs that correspond to the same keys on keyboard. I strongly recommend using keymap
instead. (My native language is not English too, and I'm using similar keymap
configuration as I described above.)