Why does this .vimrc display work in the terminal (but this happens in MacVim): map <S-Enter> O <Esc>

I have two lines in my .vimrc file:

map <S-Enter> O<Esc> map <CR> o<Esc> 

The second line works as expected, but the first line does not work.

The idea is that if I press the Enter key, vim should insert a new line at the cursor position and move the cursor down to that line. If I press Shift-Enter, vim should insert a new line above the cursor position and move the cursor to that line. This mapping should work because the main O key from normal mode will insert a new line above the cursor line, place the cursor at the beginning of this line, and then put the user in insert mode. Capital O followed by <Esc> should simply return vim back to command mode.

I checked, and capital O works as I expect. So why is my mapping not working? I tried using map <Shift-CR> and map <Shift-Enter> , and none of them do the trick.

EDIT Turns out this works on MacVim, but not iTerm. If anyone can explain why and suggest a workaround, I would appreciate it.

+8
vim
source share
1 answer

Do you use a Vim console? Some key combinations can only be displayed in GVIM. In all / most Linux terminals, Enter cannot be combined with Shift or Ctrl . Your mapping is correct in itself, but you will have to use a different LHS in the mapping.

Because keyboard input is internal, some key combinations cannot be used even in GVIM. Some key combinations, such as Ctrl + non-alphabetic, cannot be displayed, but Ctrl + letter vs. Ctrl + Shift + letter cannot be selected. This is a well-known pain point and the subject of various discussions on the vim_dev and #vim IRC channel.

Some people (primarily Paul Levnerd Evans) want to fix this (even for the Vim console in terminals that support this), and have issued various suggestions, cf. http://groups.google.com/group/vim_dev/browse_thread/thread/626e83fa4588b32a/bfbcb22f37a8a1f8

But to date, no patches or volunteers have yet been released, although many have expressed a desire to have this in a future release of Vim 8.

+11
source share

All Articles