Trouble mapping <C-j> in Vim with latex-suite

强颜欢笑 提交于 2020-01-01 09:05:43

问题


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:

  1. After map <C-j> <C-w>j, <C-j> goes into Insert mode.
  2. 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:

  1. firstly, target the mappings:

    nnoremap <C-j> <C-w>j
    
  2. 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.




回答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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!