tomlhelix-editor

How can I map the ñ key on the Helix text editor?


I opened ./helix/config.toml to set some keymaps and since I am a spanish speaker I wanted to add a functionality to the ñ key.

I added the following configuration:

[keys.normal]
ñ = "move_char_right"

When I tried to reopen Helix it said the following:

Bad config: unexpected character found: `\u{f1}` at line 13 column 1
Press <ENTER> to continue with default config

I tried to reference it with both UFT and hex and none of them seemed to work (probably because the keys were set as an Enum or a Struct). So here I am asking.


Solution

  • This is part of the TOML syntax: To use characters other than ASCII letters, digits, underscores, or dashes in keys, the key itself needs to be in quotes.

    [keys.normal]
    "ñ" = "move_char_right"
    

    See "bare keys" and "quoted keys" in https://toml.io/en/v1.0.0#keys. Quoting from there, but omitting examples:

    Bare keys may only contain ASCII letters, ASCII digits, underscores, and dashes (A-Za-z0-9_-). Note that bare keys are allowed to be composed of only ASCII digits, e.g. 1234, but are always interpreted as strings.

    Quoted keys follow the exact same rules as either basic strings or literal strings and allow you to use a much broader set of key names. Best practice is to use bare keys except when absolutely necessary.