I wanted to map <C-j>
to switch to the next window below the current one
map <C-j> <C-w>j
However, it goes into Insert mode instead of moving the window below. Why?
I have latex-suite
installed. So I tried to query what <C-j>
is mapped to
:map <C-j>
And I get the following output:
v <NL> <Plug>IMAP_JumpForward
n <NL> <Plug>IMAP_JumpForward
o <NL> <C-W>j
This means that I should change the mapping of <Plug>IMAP_JumpForward
. I read around a bit and I found out it's related to the <++>
placeholders that you can jump to using <C-j>
during Insert mode. So, based on my reading, I learned I could change the mapping using the following line in .vimrc
:
imap <C-space> <Plug>IMAP_JumpForward
But no, it doesn't work as <C-j>
used to. I'll try to illustrate. I type the following (the _
represents the cursor):
\documentclass{}_
Then I get
\documentclass{_}<++>
Then I try to type in some text
\documentclass{article_}<++>
So now I press <C-space>
. This is what happens: it goes out of Insert mode and I'll be in the following situation:
\documentclass{articl_e}<++>
map <C-j> <C-w>j
, <C-j>
goes into Insert mode.imap <C-space> <Plug>IMAP_JumpForward
, <C-space>
doesn't jump to the next <++>
placeholder. It goes out of Insert mode and cursor backs up one character.What's the matter? Anything I missed?
I suggest two things:
firstly, target the mappings:
nnoremap <C-j> <C-w>j
secondly, find out what mappings interfere (and where they come from) by doing
verbose nmap <C-j>
verbose nmap <C-w>
verbose nmap j
see also :map
, :imap
, :vmap
, :noremap
etc.
I have had the same problem; for me, it was behaving weirdly since the <C-j>
from vim-latex is mapped for the normal visual and insert modes. I kind of felt that after seeing this answer and checking the 'imaps.vim' file in the '\bundle\vim-latex\plugin' directory. I put the following code in my vimrc and it seems to work.
imap <C-space> <Plug>IMAP_JumpForward
nmap <C-space> <Plug>IMAP_JumpForward
vmap <C-space> <Plug>IMAP_JumpForward
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With