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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With