Search code examples
vim

vim ignores keymapping, provided in .vimrc


I have a .vimrc file (hosted in a git-repo), containing the following keymappings:

map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h

But recently, the mapping <c-j> stopped working, causing <c-j> to change to insert-mode.

My git-repository does not show any changes, but the :map command returns:

o  <NL>          <C-W>j
   <C-K>         <C-W>k
   <C-L>         <C-W>l
   <C-H>         <C-W>h

What could be the reason? And what does the <NL> stand for?

  • Executing :map <c-j> <c-w>j after vim started, fixes the mapping.
  • Doing a noremap <c-j> <c-w>j does not fix the problem
  • Moving the mapping to the end of the vimrc-file also causes no success...

EDIT 1.0:

:verbose map <c-j> returns:

v  <NL>          <Plug>IMAP_JumpForward
    Last set from ~/.vim/bundle/vim-latex-suite/plugin/imaps.vim
n  <NL>          <Plug>IMAP_JumpForward
    Last set from ~/.vim/bundle/vim-latex-suite/plugin/imaps.vim
o  <NL>          <C-W>j
    Last set from ~/.vimrc

EDIT 2.0:

Disabling vim-latex-suite makes the mapping work again. But how can I combine both? Plugin+mapping?


Solution

  • The vim-latex-suite plugin overrides your <C-J> mapping. (I don't know why it defines a global mapping; a buffer-local one for Latex files might suffice, but I don't know the plugin.) As the plugin supplies <Plug> mappings, it's easy to redefine the conflicting one in your ~/.vimrc, e.g.:

    nmap <Leader>j <Plug>IMAP_JumpForward
    

    Under :help key-notation, you'll see that <C-J> and <NL> are equivalent. May Control key codes have special meaning:

    <NL>      linefeed        CTRL-J   10 (used for <Nul>)