vim: Improve handling of German keybindings

Automatically map them when setting the spelllang to de and unmap them
when switching back to another language.
This commit is contained in:
2020-11-25 02:14:22 +01:00
parent 0ff4ffd67d
commit 90ab5eaf25

View File

@@ -141,14 +141,28 @@ noremap! <C-H> <C-W>
" Correct word with best/first suggestion. " Correct word with best/first suggestion.
noremap <leader>c 1z= noremap <leader>c 1z=
" Umlaute and sz " Umlaute and sz in Insert and Command-line mode when spelllang is set to de
map! ae ä autocmd OptionSet spelllang call NewSpellLang(v:option_new, v:option_old)
map! Ae Ä function! NewSpellLang(new_lang, old_lang)
map! oe ö let mappings = {
map! Oe Ö \ 'ae': 'ä',
map! ue ü \ 'Ae': 'Ä',
map! Ue Ü \ 'oe': 'ö',
map! sz ß \ 'Oe': 'Ö',
\ 'ue': 'ü',
\ 'Ue': 'Ü',
\ 'sz': 'ß',
\ }
if (a:new_lang == 'de')
for [key, value] in items(mappings)
execute 'map! <buffer>' key value
endfor
elseif (a:old_lang == 'de')
for key in keys(mappings)
execute 'unmap! <buffer>' key
endfor
endif
endfunction
" Jump through jump table but center " Jump through jump table but center
noremap <Tab> <Tab>zz noremap <Tab> <Tab>zz