I write in English and Swedish in vim and have the lines below in my .vimrc
to switch to and from a pseudo-Swedish keyboard layout. Basically some keys are remapped with inoremmap
when doing <Leader>s
to output Swedish characters, and characters that are masked by this are reached by hitting the key twice. <Leader>e
undoes these mappings to return to English typing. This all works fine except for with the r
operation. For example, when the Swedish mappings are in effect, r[
does not change the letter to å
, but to [
. How can I make these mappings also affect the r
operation?
Note that I do not want to use the OS's keyboard switch since this would effect operations in normal mode.
" Switch to Swedish
function! SweType()
set spelllang=sv
inoremap ; ö
inoremap ;; ;
inoremap : Ö
inoremap :: :
inoremap [ å
inoremap { Å
inoremap ' ä
inoremap '' '
inoremap " Ä
inoremap "" "
inoremap [[ [
inoremap {{ {
endfunction
nmap <Leader>s :<C-U>call SweType()<CR>
" Switch to English
function! EngType()
set spelllang=en_us
inoremap ; ;
iunmap ;;
inoremap : :
iunmap ::
inoremap [ [
iunmap [[
inoremap { {
iunmap {{
inoremap ' '
iunmap ''
inoremap " "
iunmap ""
endfunction
nmap <Leader>e :<C-U>call EngType()<CR>
:help 'langmap'
.