1

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>

1 Answers1

2

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.

Edit:

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).

yolenoyer
  • 320
  • 2
  • 8
  • 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 Mar 23 '18 at 09: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 Mar 23 '18 at 09: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 Mar 23 '18 at 09:53
  • @yolenoyer: my issue has been resolved. it was /etc/vim/vimrc – MD. Mohiuddin Ahmed Mar 23 '18 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. – Rafael Toledo Oct 18 '23 at 13:45