1

On a Swedish keyboard to the right of the keyboard one has: O, P, Å L, Ö, Ä

[ and ] are extensively used by Vim, and hard to reach on my keyboard, so therefore I've mapped these to Ö and Ä in my .vimrc file.

map ö [
map ä ]

I'd like <leader>[, or in reality <leader>ö to move a line up. So I've tried:

" Does not work
nmap <leader>[ :m .+1<CR>==
" Works
nmap <leader>ö :m .+1<CR>==

Note that I don't want to have special characters Ö and Ä in my vimrc file, in order to keep it universal. I've tried different combinations of map, nmap, and nnoremap, without success. Note that I always want Ö and Ä to be remapped, except for when writing in insert mode. Now I can use them normally in insert mode, which is unexpected.

How should I go about this?

Max
  • 153
  • 3
  • 3
    Are you looking for :h 'langmap'? Something like set langmap=ö[ to make ö behave like [ in normal mode and then your mapping should work. (Also unless you know what you are doing, you should use the non recursive version of the mapping commands nnoremap) – statox May 07 '20 at 09:15
  • I tested set langmap=ö[ä] but didn't work still. Still, this mapping works nnoremap <leader>ö :m .+1<CR>==, this doesn't nnoremap <leader>[ :m .+1<CR>==. – Max May 08 '20 at 14:33
  • A thought, could it be that using the normal [] keys requires me to use ALT-GR, and they don't work with the leader key. This seems to be related to meta keys sending some key combination that includes an ESC, or something similar. Maybe the mappings work, but it's the map to the bracket that messes it up. – Max May 08 '20 at 14:40
  • I just tried this one and couldn't make 'langmap' work either... In theory it should work, so I don't know why it doesn't... Is it completely broken? Not very sure how to troubleshoot it either since the translation happens at a fairly low level... Maybe need to increase verbosity to understand what's going on there? – filbranden May 10 '20 at 20:58
  • Hi, can I assist you with here? Good that the bug is reproducible. – Max May 11 '20 at 07:28

0 Answers0