Vim: Bind <C-Enter>

5,728

I'm guessing you're using Vim inside a terminal, since I was able to map <C-Enter> successfully in the GUI versions of both MacVim on OS X and gVim on Windows:

:imap <C-Enter> I just pressed Control+Enter<CR>

If you're using the terminal version of Vim, then Vim is at the mercy of whatever keycodes the terminal provides. In some terminals, pressing Control+Enter looks exactly the same to Vim as pressing Enter alone, so Vim never really sees the keystroke you're trying to send it.

See this older Stack Overflow question for additional discussion:

https://stackoverflow.com/questions/598113/can-terminals-detect-shift-enter-or-control-enter

Share:
5,728

Related videos on Youtube

mtkoan
Author by

mtkoan

Updated on September 17, 2022

Comments

  • mtkoan
    mtkoan over 1 year

    Using vim for editing latex; how can I bind C-Enter? I tried the following, which does not work:

    imap <C-Enter> \\<CR>
    

    and

    imap <C-Return> \\<CR>
    

    However, something like:

    imap <C-i> \\<CR>
    

    Does work.

    Any ideas are suggestions for vim latex-addons?

  • mtkoan
    mtkoan about 14 years
    I'm afraid this does not work either.
  • Ferdinand Prantl
    Ferdinand Prantl over 10 years
    The accepted answer of the linked question gives a solution which worked for me: imap <C-J>.