{"action":"created","issue":{"url":"https://api.github.com/repos/neovim/neovim/issues/2420","labels_url":"https://api.github.com/repos/neovim/neovim/issues/2420/labels{/name}","comments_url":"https://api.github.com/repos/neovim/neovim/issues/2420/comments","events_url":"https://api.github.com/repos/neovim/neovim/issues/2420/events","html_url":"https://github.com/neovim/neovim/issues/2420","id":68056970,"number":2420,"title":"Supporting non-English keyboards properly","user":{"login":"HiPhish","id":4954650,"avatar_url":"https://avatars.githubusercontent.com/u/4954650?v=3","gravatar_id":"","url":"https://api.github.com/users/HiPhish","html_url":"https://github.com/HiPhish","followers_url":"https://api.github.com/users/HiPhish/followers","following_url":"https://api.github.com/users/HiPhish/following{/other_user}","gists_url":"https://api.github.com/users/HiPhish/gists{/gist_id}","starred_url":"https://api.github.com/users/HiPhish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HiPhish/subscriptions","organizations_url":"https://api.github.com/users/HiPhish/orgs","repos_url":"https://api.github.com/users/HiPhish/repos","events_url":"https://api.github.com/users/HiPhish/events{/privacy}","received_events_url":"https://api.github.com/users/HiPhish/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/neovim/neovim/labels/ux","name":"ux","color":"c7def8"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-13T09:47:27Z","updated_at":"2015-04-13T19:06:29Z","closed_at":null,"body":"Hello, NeoVim team\r\n\r\nI am a Vim user with a non-English keyboard layout and I wonder if it would be possible to fix things in NeoVim. I've described the problem and my proposition in a pastebin:\r\nhttp://pastebin.com/QeLFUGA1\r\n\r\nIs this even possible? I don't know if a terminal is able to register `ctrl` + `key` as two different keys, or if they get lumped into one control character. I know that at least my OS can do that: in Safari on OS X if I hold down the `ctrl` key the status bar says \"Display a menu\", because on OS X left-clicking while holding ctrl is like right-clicking.\r\n\r\nIf NeoVim could do that it would be a killer feature at least for me as a non-English user. I know C (see my GitHub repositories), but I have never worked on big projects, so I have no idea where to start. If this issue is feasible and someone were to tackle it I would gladly contribute as best as I can.\r\n\r\nI case the pastebin is unavailable, here is the abridged version:\r\n\r\nMotivation\r\n----------\r\n\r\nThe default keyboard commands in Vim are easy to remember and easy to type when\r\nyour only language is English. Keystrokes like `daw` intuitively expand to\r\n*delete around word* in the user's mind and are simple enough to type quickly.\r\n\r\nHowever, when using a non-English keyboard layout Vim becomes unusable. Even if\r\nthe language in question is using the Latin alphabet non-letter keys will be\r\nawkward to reach. For instance, the `:` key will be below the `l` key on a\r\nGerman keyboard, making such an important key very uncomfortable to reach. If\r\nthe keyboard is using a different alphabet, such as Cyrillic, even the most\r\nbasic tasks become impossible. I am not talking about hypothetical scenarios,\r\nThese are the issues I face every day.\r\n\r\nPossible solution in Vim - first attempt\r\n----------------------------------------\r\n\r\nVim offers the `langmap` feature: every character gets mapped to a corresponding\r\nother character:\r\n\r\n    :set langmap=ü[,+],ö\\\\;,ä',#\\\\\\\r\n\r\nThis will map the lower-case home row to act like the home row on an English\r\nkeyboard. This is similar to the tip about using a Dvorak keyboard with default\r\nVim commands:\r\n\r\nhttp://vim.wikia.com/wiki/Using_Vim_with_the_Dvorak_keyboard_layout\r\n\r\nJust as described in the link, this method has problems: for instance using the\r\nmapped keys is impossible in multi-key mappings:\r\n\r\n    noremap <C-[> a\r\n\r\nThis will work fine with the physical `[` key (alt + 5 on German Mac keyboards),\r\nbut not with the `ü` key which has be mapped to act like the `[` key. This is\r\nnot just a problem with umlauts, but with any character. Assume we wanted to\r\nswap the function of `:` and `;`:\r\n\r\n    noremap : ;\r\n    noremap ; :\r\n\r\nThis will again work with the physical keys, but not with the mapped ones. This\r\nis an inconvenience on Latin keyboards, but utterly crippling on a Cyrillic one.\r\n\r\nPossible solution in Vim - second attempt\r\n-----------------------------------------\r\n\r\nLangmap is an elegant feature, but not suitable for the job. Let's get more\r\nlow-level by explicitly remapping keys:\r\n\r\n\tnoremap ü [\r\n\tnoremap + ]\r\n\tnoremap ö ;\r\n\tnoremap ä '\r\n\tnoremap # \\\r\n\r\nThis has the exact same limitations as the above attempt.\r\n\r\nPossible solution in Vim - third attempt\r\n----------------------------------------\r\n\r\nLooking at the two above a common theme can be seen: we map some character to\r\nanother character and then map that to something else. So how about condensing\r\nthese mapping into one? For example, swapping the `:` and `;` keys becomes:\r\n\r\n\tnoremap ö :\r\n\tnoremap Ö ;\r\n\r\nThis works great for single keys and ASCII key-combos. It does not work for key\r\ncombos with non-ASCII characters:\r\n\r\n    noremap <C-Ü> <C-[>\r\n\r\nPressing ctrl + ü will not do anything. Furthermore, one has to do this for\r\nevery single keyboard layout. Instead of mapping every layout to English as a\r\ncommon base and then mapping those keys to my liking I have to condense mappings\r\nmanually every time.\r\n\r\nPossible solution in Vim - fourth attempt\r\n-----------------------------------------\r\n\r\nIf the problem cannot be fixed at Vim level it has to be fixed at OS level:\r\nchange the keyboard layout for the OS. This works perfectly, but requires\r\nswitching keyboard layouts all the time. We can map English characters to\r\nnon-English targets in insert mode, but even then the user still has to switch\r\nkeyboard layouts when entering Vim and when leaving Vim. This could maybe be\r\nautomated at the OS-level but it's still an ugly hack around a problem that's in\r\nVim.\r\n\r\nAnalysis of the solutions\r\n-------------------------\r\n\r\nMy goal is to have a sort of neutral keyboard layout which can then be further\r\ncustomised to my liking. This keyboard layout is the English one, since that's\r\nwhat Vim was created for. Every other layout gets mapped to English before\r\nfurther mapping.  Here is a sketch:\r\n\r\n    German:   ö -> ; -> :\r\n    Cyrillic: ч -> ; -> :\r\n\r\nBoth the keys `ö` and `ч` get mapped to a common base, the English key `;`.\r\nTherefore language mappings need to take precedence over other mappings. This\r\nneeds to work implicitly with key combos as well:\r\n\r\n    ü -> [  ===>  <C-Ü> -> <C-[>\r\n\r\nThe user should not have to specify the second mapping, it should be implied by\r\nthe first one. Using `map` instead of `noremap` is not an option either if I\r\nwant to swap keys:\r\n\r\n    map ; :\r\n    map : ;\r\n\r\nThis will just run in circles. Recursive mapping can also interfere with\r\nmappings used in plugins.\r\n\r\nConclusion\r\n----------\r\n\r\nUsing keys quickly enters muscle memory and it would make sense to perform the\r\nsame actions with the same finger motions. Manipulating lines of text is the\r\nsame regardless of the language the text was written in, even if the text is\r\nsome pseudo-Latin *Lorem ipsum*. To prevent redundancy the keys pressed by the\r\nuser are first mapped to their English equivalents and then the English keys are\r\nmapped according to the user's settings. That way the process of manipulating an\r\nEnglish, German or Cyrillic text is the same, and only the process of typing it\r\nis language-dependent."},"comment":{"url":"https://api.github.com/repos/neovim/neovim/issues/comments/92463915","html_url":"https://github.com/neovim/neovim/issues/2420#issuecomment-92463915","issue_url":"https://api.github.com/repos/neovim/neovim/issues/2420","id":92463915,"user":{"login":"HiPhish","id":4954650,"avatar_url":"https://avatars.githubusercontent.com/u/4954650?v=3","gravatar_id":"","url":"https://api.github.com/users/HiPhish","html_url":"https://github.com/HiPhish","followers_url":"https://api.github.com/users/HiPhish/followers","following_url":"https://api.github.com/users/HiPhish/following{/other_user}","gists_url":"https://api.github.com/users/HiPhish/gists{/gist_id}","starred_url":"https://api.github.com/users/HiPhish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HiPhish/subscriptions","organizations_url":"https://api.github.com/users/HiPhish/orgs","repos_url":"https://api.github.com/users/HiPhish/repos","events_url":"https://api.github.com/users/HiPhish/events{/privacy}","received_events_url":"https://api.github.com/users/HiPhish/received_events","type":"User","site_admin":false},"created_at":"2015-04-13T19:06:29Z","updated_at":"2015-04-13T19:06:29Z","body":"OK, I didn't want to bloat the post with too much text, but I have edited it now."}}