Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing keyboard layout between insert and normal mode

Tags:

vim

windows-7

In my daily work in Vim's insert mode I use my native Croatian keyboard layout (HR) to which I'm accustomed at. In normal mode it is more practical for me to be in English keyboard layout (EN) since it has brackets [] and curved parenthesis {} and generally Vim's shortcuts make better use of it.

Is there a way to change keyboard modes automatically between modes?

like image 485
Rook Avatar asked Oct 15 '25 18:10

Rook


1 Answers

Vim can use keymap files to translate typed keys in insert mode; it even ships with a Croatian one ($VIMRUNTIME/keymap/croatian.vim)! :help mbyte-keymap explains this well:

When the keyboard doesn't produce the characters you want to enter in your text, you can use the 'keymap' option. This will translate one or more (English) characters to another (non-English) character. This only happens when typing text, not when typing Vim commands. This avoids having to switch between two keyboard settings.

Basically, this configuration should do it (together with using an English keyboard layout in the operating system):

:set keymap=croatian

Any you use it like that:

In Insert and Command-line mode you can use CTRL-^ to toggle between using the keyboard map or not. This flag is remembered for Insert mode with the 'iminsert' option.

like image 109
Ingo Karkat Avatar answered Oct 18 '25 14:10

Ingo Karkat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!