I have set up some langmaps, notably ü< and ó> on my Hungarian keyboard. I also installed machakann/vim-swap which binds g< and g> to swap arguments in a function. The plugin works with g<altgr>í and g<altgr>y which is the default way to get these characters on my keyboard, but will not work with and . I tried set langremap but that didn't help. In fact actually triggers vim's original g<which loads the previous command output.

Any idea on how to get this working properly?

  • Try the opposite, set nolangremap. I believe the default is on and disabling it might be the sane setting (from my reading of the help docs.) – filbranden Dec 11 '20 at 11:19
  • hmm, now the default (command output) behaviour doesn't trigger, but neither does what I want :) I guess langmap has it's limitation. E.g. I just found out that if I have a langmap for Ő} moving around the paragraphs work but will not jump as f}. This might actually be a good thing, still :) – fbence Dec 11 '20 at 11:54
  • 1
    I'd still like to understand what is going on, but the workaround for now is explicitly mapping with nmap gü <Plug>(swap-prev) and ` nmap gó <Plug>(swap-next)` – fbence Dec 11 '20 at 11:58
  • I think this might be a bug... If I use set langmap=[< or set langmap=(< it works correctly (with g[ or g(, resp.), but set langmap=é< and using doesn't work for me (with a simple nmap g< gU_ for testing). – filbranden Dec 11 '20 at 15:13

This seems to be a bug in Vim's handling of 'langmap'. I can consistently reproduce it and it seems to only happen when using a "from" character on the 'langmap' that is outside of the basic 7-bit ASCII range (letters, numbers, basic symbols.)

I reported the issue upstream here: https://github.com/vim/vim/issues/7458 (I'll update this answer once there's a fix for it.)

For now, as you reported in comments, adding specific mappings seems to be a functioning workaround:

nmap gü <Plug>(swap-prev)
nmap gó <Plug>(swap-next)

In the comments, you also asked about how the 'langmap' interacts with commands such as f, F, t and T. For those, as well as r (to replace a single character), the 'langmap' settings are intentionally not used.

There's a separate :lmap command (separate from the 'langmap' settings) that allow you to create similar mappings to the ones from 'langmap', but that work in other situations, which include the f, F, t and T motions and the r command.

But these also may affect the Ex command-line, the line when entering a search pattern (after / or ?) and they may also affect how the key behaves in Insert mode. There's a handful of additional settings to control those, and also key bindings such as CTRL-^ to switch the behavior in each of those modes. (Warning, the rabbit hole goes deep from here.) See :help language-mapping for all the gory details (you'll need to read that carefully and probably experiment with it to find what works well in your case.)

  • 1
    Thanks! I have a weird feeling of accomplishment that I managed to run into a bug in -vim_ :D Also, that rabbit hole looks a lot deeper than what I'm hoping to gain on first glance, but I'll think on it. (I would not want to mess with insert mode, on the other hand, I usually use vim to type code, which rarely involves writing in Hungarian, so maybe switching could work ...). – fbence Dec 11 '20 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.