问题
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?
Solution attempted:
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}<++>
Problem summary:
- After
map <C-j> <C-w>j,<C-j>goes into Insert mode. - After
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?
回答1:
I suggest two things:
firstly, target the mappings:
nnoremap <C-j> <C-w>jsecondly, 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.
回答2:
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
回答3:
I found the sollution here: How to debug vim mapping overlaps?
You should use
nnoremap <SID>I_won’t_ever_type_this <Plug>IMAP_JumpForward
So the imaps.vim of vim-latex don't remap . You can still have the functionality by mapping to something better.
来源:https://stackoverflow.com/questions/8304421/trouble-mapping-c-j-in-vim-with-latex-suite