I have inoremap jj <ESC> in my vimrc on my Ubuntu 16.04. I have no idea why my jj not working and its just typing literally <ESC> in my text file for my jj press.

Any idea how can I get around this?
My full vimrc:

map j gj
map k gk

set smartindent
set nowritebackup  
set noswapfile     
set nobackup

colo delek
inoremap jj <ESC>
  • Id bet money its the first mapping causing problems. What happens if you use nnoremap instead of map?
    – D. Ben Knoble
    Commented Mar 23, 2018 at 8:32
  • 1
    If you can't make the mapping with <esc> to work you can try inoremap jj ^[ where ^[ is inserted by pressing <ctrl-v><Esc> (Also I wrote a question which may help you How to debug a mapping? )
    – statox
    Commented Mar 23, 2018 at 9:28
  • @DavidBenKnoble: It looks like nnoremap not working either Commented Mar 23, 2018 at 11:37

1 Answer 1


At the beginning of your vimrc (before your mappings), you should add:

set nocompatible

It will change many behaviours inside vim (see help), and will certainly solve your problem.

Here is a similar question on SuperUser.


If this solution works, however it means that the compatible option has not been automatically unset by Vim, which however should happen in most cases (see :h compatible-default).

It probably means that you're not using a user vimrc configuration file, like ~/.vimrc. In this case, Vim would unset the compatible option automatically. So a better solution would be to put your configuration in such a file (see :h .vimrc for other possible names that Vim will be able to detect).

  • 1
    That will not change anything see :h 'nocompatible': When a |vimrc| or |gvimrc| file is found while Vim is starting up, this option ['nocompatible'] is switched off. This command shouldn't be in your vimrc actually because it reset different settings which can cause trouble when you source your vimrc after start up
    – statox
    Commented Mar 23, 2018 at 9:19
  • 2
    @statox: From :h compatible-default: [...] then the option will be set to 'nocompatible'. [...] Note that this does NOT happen when a system-wide vimrc file was found. Maybe it's the case for the OP? And how could the described behaviour be explained otherwise than with compatible set?
    – yolenoyer
    Commented Mar 23, 2018 at 9:46
  • @yolenoyer Might be worth adding that info to your answer, and maybe also the suggestion to move the configuration into a personal .vimrc as an alternative solution?
    – Rich
    Commented Mar 23, 2018 at 9:53
  • @yolenoyer: my issue has been resolved. it was /etc/vim/vimrc Commented Mar 23, 2018 at 11:44
  • thank you so much. I changed computers, and my vim settings just stopped worked as usual. Only after set nocompatible, my commands from vimrc started working again. I have installed and uninstalled and removed all vim folders, but the problem persisted, I don't know why. Commented Oct 18, 2023 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.