Programmer's VIM setup for Finnish/Swedish or other non-US keyboard layout

為{幸葍}努か 提交于 2019-12-02 17:58:26

I just keep the keyboard with US layout when coding and only switch to local layout (italian) when writing text that requires accented letters or other language specific characters. After all it's just a keypress to switch and nothing beats US layout for programming. I tried a bit but found that specifying lots of mappings to work around this is far more troublesome than a full layout switch on need.

My solution is to use custom mix of US and FIN/SWE layouts. Works quite nicely(or at least better than the horrible fin layout).

That image probably does not have all the characters I do, but most of them anyways.

You can use the langmap and keymap setting whtin VIM. I use it for colemak. You can specify your own layout.

h keymap
h langmap

As a practical stopgap, could you not simply switch between layouts?

For example, in Ubuntu, you can set up hotkeys to easily switch between layouts by going to Preferences → Keyboard → Layouts → Options → Key(s) to change layout. I use both Shift keys to quickly move between layouts, and there's even an option so that each window has its own layout setting, which works well if you're programming in Vim in a U.S. English layout while writing documentation/emails/etc. in other windows in a different layout. Even if I have to switch layouts (for code comments, etc.), it takes very little effort to hit both Shift buttons and carry on.

There should be similar ways to configure this in other desktop environments / operating systems.

My solution for this was that I made a custom keyboard layout, which combines the best aspects of the US layout in to the Finnish one. The nice thing about it is that it keeps the changes to a minimum so that the learning curve is practically non-existent.

The philosophy behind it was to minimise the need to use AltGr, and still keeping it as close to the standard Fin layout as possible. And even though there are some keys under AltGr, you never have to press them awkwardly with your right hand while holding the modifier with your thumb.

The programs I used to make the layout were Ukelele for macOS and Microsoft Keyboard Layout Creator for Windows. I'm calling it Finner.keylayout / Finner.klc.

Here's the basic layout (it has a lot more keys under modifiers) with the changed keys highlighted:

I simply have mapped those ctrl- combos to other keybindings.

For instance, ctrl-] is mapped to meta- down .

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!