user258346
user258346

Reputation: 115

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?


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?

Upvotes: 0

Views: 365

Answers (2)

Rudolf
Rudolf

Reputation: 1

Had a similar problem on vim on Solaris 11. The command :map written in ./vim80/vimrc has been ignored. This is the code:

map <Space>w :w!<CR>
map <Space>q :q!<CR>
map <Space>k Y
map <Space>v p

I use this to avoid typing too much:
Space w does the same as Shift : w Shift ! Enter.

The solution was to write the code not in vimrc but in defaults.vim

I had this problem only on Solaris 11 on a virtual machine. Other unix distributions like RedHat or Debian and also vim on Windows worked as expected, namely with the :map-code in vimrc.

Upvotes: 0

Ingo Karkat
Ingo Karkat

Reputation: 172570

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

Upvotes: 2

Related Questions