Since I have solved this myself with the help of comments by @Chris Heithoff I'm going to answer it myself. As comment stated: when some mapping should work but it didn't, thne the reason is probably because some plugins also doing the mapping for the same key. To check it:
:verbose imap YOUR_KEY
where YOUR_KEY
is optional, if omitted then all will be listed. And I found this is useful since I want to read them in a larger window.
If you're interested about the intent of <BS>
to <Nop>
mapping:
In short:
- Alacritty doesn't support inline editing when typing Chinese in insert mode.
- For example, there are 3 components
ㄋㄧˇ
to form the word 妳
, Both these components and the result 妳
will not be shown in insert mode before I hit Enter
after typing them all.
- Even worse, if I want to delete some component before I hit the
Enter
, it will delete not only the last component BUT ALSO the word already entered before 妳
. (I hate it!)
So what I wanted to do is a shortcut to toggle <BS>
when entering insert mode. Here is the result :)
" Chinese Input.
inoremap <Up> <Nop>
inoremap <Down> <Nop>
inoremap <Left> <Nop>
inoremap <Right> <Nop>
inoremap <nowait> <C-C> <Esc>:call <SID>toggleLockOnBS()<CR>a
inoremap <nowait> <Esc> <Esc>:call <SID>removeBSLock()<CR>
let s:lockOnBS=0
function! s:toggleLockOnBS() abort
if s:lockOnBS
call s:removeBSLock()
else
call s:putBSLock()
endif
endfunction
function! s:removeBSLock() abort
execute 'inoremap <buffer><silent> <BS> <C-R>=AutoPairsDelete()<CR>'
echo '<BS> enabled for 中文.'
let s:lockOnBS = 0
endfunction
function! s:putBSLock() abort
execute 'inoremap <buffer><silent> <BS> <Nop>'
echo '<BS> disabled for 中文.'
let s:lockOnBS = 1
endfunction
the line inoremap <buffer><silent> <BS> <C-R>=AutoPairsDelete()<CR>
is to restore the mapping of some plugin which also want to map <BS>
to something else. Feel free to change it to whatever you like.
inoremap <BS> <Nop>
command worked both in Vim and NeoVim for me.verbose imap <BS>
to report what, if anything, <BS> is mapped to.<BS>
when certain input-method is chosen. I need the auto-pairs plugin, lol.