0

I have a Swiss keyboard where the ']' is created with the CTRL-ALT-5 key combination. I remapped it to the 'à' character as so:

keymap.set({"n", "o", "x"}, "à", "]", {remap = true})

The remap works in normal mode but not in the help files. What am I doing wrong?

6
  • Any special reason for using remap = true? This is usually not what you'd want. And why not use <C-]> as mapping target as this seems to be the command you ultimately want to run?
    – Friedrich
    Jan 22 at 9:40
  • That is true, it didn't cross my mind to create a mapping for <C-]>. Done and working, thank you
    – kaklon
    Jan 22 at 11:23
  • Glad you fixed it. You might post an answer for your own question to help other users. You can accept your own answer after two days.
    – Friedrich
    Jan 22 at 11:41
  • Why did they call that option "remap"? Sigh…
    – romainl
    Jan 22 at 12:40
  • @romainl probably because Vim's :help map.txt uses "remap[ping]" in this specific meaning.
    – Friedrich
    Jan 22 at 14:38

1 Answer 1

0

Create a mapping for the actual command you want to use. That's <C-]> in this case.

Some minor remarks: using a non-recursive mapping is preferred both in general and in this instance. Mapping in operator-pending mode seems superfluous but that's the default. Either use the default or create the mapping only for normal and visual modes.

The resulting Lua code would be either of the two

keymap.set({"n", "x"}, "à", "<C-]>")
keymap.set("", "à", "<C-]>")

The latter would be equivalent to the following Vimscript:

:noremap à <C-]>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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