1

I'm new to vim and currently trying to understand the different commands. :help index shows me a list of all commands for each mode. Section 2.3 is about "Square bracket commands" like [* and ]*.

I'm using a Swiss German keyboard. The positions for [ and ] are more ore less the same as they are on a US keyboard but on a Swiss keyboard I have to keep Alt Gr pressed to reach the brackets. By just pressing the keys (without Alt Gr) I get ü (instead of [) and ¨ instead of ].

Is it possible to map all square bracket commands like so?

  • [* to ü* and
  • ]* to ¨*

I think that would be more comfortable.

1 Answer 1

1

I would add to your .vimrc:

nnoremap ü [
nnoremap ¨ ]
...
8
  • When I type the ¨ while writing this comment, it behaves as a dead key. But on my gnome-terminal it doesn't; it prints it immediately. So I assume it would work (I have to try). But I was hoping there is a way to tell VIM to treat "ü" generally as "[" for all cases (just in normal mode of course) instead of having to remap everything. Sure, it's a finite set anyway.
    – Arber
    Commented Feb 15, 2023 at 14:09
  • Thank you for your help! Actually I didn't use any of the square bracket commands so far. But I did now two tests: nnoremap ¨D ]D and nnoremap üf [f and it worked. I verified it by the error message that is shown after sending this commands. They was the same error messages. Btw. I'm using the Swiss German layout. Can you confirm, that it isn't possible to map them all with one line per bracket ([ ])?
    – Arber
    Commented Feb 15, 2023 at 14:42
  • 1
    I confirm that you need one line per mapping there are no ways to have wildcard in mapping. If the solution fit don't forget to validate it using the v button next to the arrow voting button. It help the question rest. I'll be glad to update it to the correct layout (maybe could you add that your are using the German Swiss layout in the question). Commented Feb 15, 2023 at 14:56
  • Btw. I could not find what [q and ]q are, which you did remap. They are not listed in section 2.3 of :help index.
    – Arber
    Commented Feb 15, 2023 at 15:01
  • 1
    I just tried nmap ü [ and nmap ¨ ]. This does allow recursive mapping, so that by pressing ü or ¨ it will be interpreted as [ respectively as ]. That way I can map all possible cases. Do you see any problem with this? If not, could you update your answer or maybe comment this why this wouldn't be a good idea? Thanks again.
    – Arber
    Commented Feb 15, 2023 at 23:11

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.