[Solved] VIM imap jj or jk is not working

There are times when we are making changes to our .vimrc file and then realize it’s gone wrong. Here are things to check when jk or jj which is mapped to Escape from Insert Mode do not work in VIM.

1. Check if you have mispelled any word. e.g. inoremap, imap

2. Check that timeoutlen is high enough [:help timeoutlen]

set timeout
set imeoutlen=2000

3. If you are using updatetime to make your terminal Escape fast, then check that it’s set to high enough. [:help updatetime]

set updatetime=2000

4. Check that cpo has not been alterered (this usually is not the case, if you altered it meaning you know what you are doing already) [:help cpo]

5. You’ve already done 1 to 4 and now you are here means, It’s likely that some plugin is messing up your settings. Check if you have any augroup as follows in your .vimrc then remove/comment it, and see if it solves your problem or not. [:help timeoutlen]

if ! has("gui_running")
    set ttimeoutlen=10
    augroup FastEscape
        autocmd!
        au InsertEnter * set timeoutlen=0
        au InsertLeave * set timeoutlen=1000
    augroup END
endif

For me, I had issue number 3 and updating my updatetime=700 fixed it.

Also check respective vim help to gain more knowledge on what each setting will do to your workflow.

Hope it helps to solve your problem. Let me know what you think about it in comment.

Leave a Reply

Your email address will not be published. Required fields are marked *