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? Commented Jan 22, 2024 at 9:40
  • That is true, it didn't cross my mind to create a mapping for <C-]>. Done and working, thank you Commented Jan 22, 2024 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. Commented Jan 22, 2024 at 11:41
  • Why did they call that option "remap"? Sigh… Commented Jan 22, 2024 at 12:40
  • @romainl probably because Vim's :help map.txt uses "remap[ping]" in this specific meaning. Commented Jan 22, 2024 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-]> 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.