程序员的芬兰语/瑞典语或其他非美国键盘布局的 VIM 设置

发布于 2024-10-06 21:31:50 字数 1089 浏览 11 评论 0原文

我最近学习了一些 VIM hackery,学到了很多有用的命令,并且使用 VIM 编辑文本变得非常高效。我正在使用芬兰语 qwerty 键盘布局(见下图),这对于编程来说非常糟糕。所有常用的编码特殊字符 ()[]{}/\ 都是通过按 shiftalt grnumber< /kbd> 键,但我已经很习惯了。我不想更改键盘布局,因为我用母语进行了大量写作和 IRC 聊天,为此我需要 äö 字符( å 对我来说没用,只有瑞典人使用它)。

我的问题是,某些 VIM 命令默认情况下有一个相当困难的键盘映射,例如 go-to-tag-under-cursor 是 ^] ,它转换为 Ctrl-AltGr-芬兰语键盘上的 9。这需要我用左手按左控制键,用右手拇指按alt gr并将右手食指延伸到数字9 键。这感觉就像使用 emacs 和/或弹奏古典吉他。不完全符合人体工程学。

键盘布局如下所示:

sweden Keyboard

注意:标记为蓝色的键是通过按 AltGr 写入的(右 alt)和相应的键。红色的是两键组合字符或死键,它们本身不发出字符。 F. 前。要输入 ü 字符,请先按 ¡^~ 键,然后按 u。重音键也是如此。这些死键在 VIM 中是不可映射的。

所以基本上我有 3 个额外的字母键 (äöå) 可用,但它们不能映射多次,修饰键不起作用和他们一起(在 VIM 中)。我可以将某些内容映射到 ä,但不能映射到 ä

现在,我正在向芬兰/瑞典或其他非美国键盘布局用户寻求有关我的 VIM 设置的想法。请分享您的按键映射、.vimrc 技巧以及其他可能有用的内容。

I've been recently learning some VIM hackery and I have learned a lot of useful commands and gotten pretty efficient at editing text with VIM. I'm using the Finnish qwerty keyboard layout (see image below) which is pretty horrible for programming. All your usual coding special characters ()[]{}/\ happen by pressing either shift or alt gr and a number key, but I'm already pretty used to that. I do not want to change my keyboard layout since I do quite a lot of writing and IRC chatting in my native language and for that I need the ä and ö characters (the å is useless for me, only the Swedes use that).

My problem is that some VIM commands have a pretty difficult keymapping by default, for example go-to-tag-under-cursor is ^] which translates to Ctrl-AltGr-9 on a Finnish keyboard. This requires me to press the left control key with my left hand, alt gr with my right thumb and extending my right index finger to the number 9 key. This feels like using emacs and/or playing classical guitar. Not exactly ergonomic.

Here's what the keyboard layout looks like:

sweden keyboard

NOTE: the keys that are marked blue are written by pressing AltGr (right alt) and the appropriate key. The red ones are two-key compose characters or dead keys which do not give out a character by them selves. F.ex. to type the ü character you first press the ¨^~ key and then u. Same goes for the accent keys. These dead keys are unmappable in VIM.

So basically I have 3 extra alphabetical keys (äöå) available, but they cannot be mapped more than once, modifier keys do not work with them (in VIM). I can map something to ä, but not Ä or <C-ä>.

Now I'm looking for ideas for my VIM setup from fellow Finnish/Swedish or other non-US keyboard layout users. Please share your key mappings, .vimrc tips and anything else that might be useful.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

幻想少年梦 2024-10-13 21:31:50

我只是在编码时保留键盘采用美国布局,并且仅在编写需要重音字母或其他语言特定字符的文本时才切换到本地布局(意大利语)。毕竟,只需按一下按键即可进行切换,没有什么比美国布局更适合编程了。我尝试了一下,但发现指定大量映射来解决这个问题比根据需要进行完整布局切换要麻烦得多。

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.

伴随着你 2024-10-13 21:31:50

我的解决方案是制作一种自定义键盘布局,它将美国布局的最佳方面结合到芬兰布局中。它的好处是它将变化保持在最低限度,因此学习曲线实际上不存在。

其背后的理念是最大限度地减少使用 AltGr 的需要,并仍然使其尽可能接近标准 Fin 布局。尽管 AltGr 下的常用键很少,但它们都位于左侧数字下方,因此您不必在用拇指按住修改器的情况下用右手笨拙地按下它们。

我用来制作布局的程序是 Ukelele 适用于 macOS,Microsoft Keyboard Layout Creator 适用于视窗。我将其称为 Finner.keylayout / Finner.klc

这是它的 GitHub 存储库:https://github.com/ruohola/finner

这是基本布局(修饰符下有更多键),其中突出显示了更改后的键:

按键布局的图像

My solution for this was that I made a custom keyboard layout, which combines the best aspects of the US layout into 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 few commonly used keys under AltGr, they are all under the left hand side numbers, so 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 its GitHub repo: https://github.com/ruohola/finner

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

Image of the keylayout

夜巴黎 2024-10-13 21:31:50

我的解决方案是使用美国和芬兰/瑞典布局的自定义组合。效果很好(或者至少比可怕的鳍布局更好)。 我的布局的图像

该图像可能没有我所拥有的所有字符,但无论如何都是大多数字符。

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). Image of my layout

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

作死小能手 2024-10-13 21:31:50

您可以在 VIM 中使用语言映射和键盘映射设置。我用它来做科尔马克。您可以指定自己的布局。

h keymap
h langmap

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
许你一世情深 2024-10-13 21:31:50

作为一个实用的权宜之计,你不能简单地在布局之间切换吗?

例如,在 Ubuntu 中,您可以通过转至首选项 → 键盘 → 布局 → 选项 → 用于更改布局的键来设置热键以在布局之间轻松切换。我使用两个 Shift 键在布局之间快速移动,甚至还有一个选项可以让每个窗口都有自己的布局设置,如果您在 Vim 中以美式英语布局进行编程,同时编写文档/电子邮件等,则该选项非常有效。在其他窗口中以不同的布局。即使我必须切换布局(用于代码注释等),也只需很少的努力即可同时按下 Shift 按钮并继续。

在其他桌面环境/操作系统中应该有类似的方法来配置它。

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.

将军与妓 2024-10-13 21:31:50

在使用瑞典键盘 25 年、使用标准瑞典布局并积极使用 Vim 几年之后,我与 OP 有着类似的想法。

我已经使用:有

" Make some keys that are often used in normal mode more easily accessible
map å \
map ö [
map ä ]
map ¤ ^
cmap ¤ ^

一段时间了,但对 ctrl-]ctrl-[ 的解决方案不太满意。我刚刚补充道:

map Ö <c-[>
map Ä <c-]>

这似乎提供了一个值得欢迎的改进(与@ruohola 已经提到的OP 的一项发现相矛盾)。

对于瑞典布局,当然没有任何解决方案是完美的,但我认为上面的组合在很少修改默认值的情况下(这是我的标准之一),给出了可接受的折衷方案。

After using a Swedish keyboard for 25 years, with a standard Swedish layout, and actively using Vim for a few years, I was having similar thoughts to the OP's.

I had been using:

" Make some keys that are often used in normal mode more easily accessible
map å \
map ö [
map ä ]
map ¤ ^
cmap ¤ ^

for a while already, but was not too happy about the solution I had for ctrl-] and ctrl-[. I have just added:

map Ö <c-[>
map Ä <c-]>

which seems to provide a welcome improvement (contradicting one of the OP's findings as already mentioned by @ruohola).

With a Swedish layout, no solution will be perfect of course, but I think that the combination above, while modifying the defaults very little (this is one of my criteria), gives an acceptable compromise.

半葬歌 2024-10-13 21:31:50

我只是将这些 ctrl- 组合映射到其他键绑定。

例如,ctrl-] 映射到 meta-

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文