1

I get a strange behavior of vim but it can be related to st-terminal that I cannot do an Enter or Ctrl+Enter to break the current line into new line in insert mode, as in the example below:

I have a line in vim that opens inside st-terminal:

This is a| test

| is the position of the cursor. I'd like to break the line into two different lines using Enter or Ctrl+Enter but I couldn't do that; vim somehow prevents me to break the line.

This is a
test

I have settings that might change Enter behavior of vim, these settings related to “UltiSnips” plugin, like below:

inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<cr>"
inoremap <expr> <Esc> pumvisible() ? "\<C-e>" : "\<Esc>"

let g:UltiSnipsExpandTrigger="<enter>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"

As I understand, the above code might lock Enter to break line in insert mode. But doesn't care about Ctrl+Enter.

UltiSnips possible locked Enter in insert mode.

I try to install xterm and do a try; it doesn't work either.

So it might relate to the OS itself? I have no idea.

I use Arch Linux, st-terminal, xterm, latest vim 8.1 / 1-374

EDIT: I tried to remove the above code in .vimrc, and Enter and Ctrl+Enter work again.

But I still need to enable the UltiSnips plugin. How can I make Ctrl+Enter break the line? It's okay to disable Enter.

I suspect possible st-terminal didn't separate Ctrl+Enter and Enter; Ctrl+Enter falls back to Enter, it actually might had been set to the same "terminal keycodes"??


I found a solution: I comment out this line to enable back Enter

let g:UltiSnipsExpandTrigger="<enter>"
Tuyen Pham
  • 1,765
  • 1
  • 16
  • 46

1 Answers1

1

Terminal applications expect bytes. There's no predefined result for control+enter, and your question does not contain the information showing what you expect it to be. Once you decide, you'll have to modify st's source-code to send the expected sequence of bytes. (You could do the same with xterm's translation resource).

Thomas Dickey
  • 75,040
  • 9
  • 171
  • 268
  • Do you mean I have to map `ctrl-enter` to `enter`? Or map `ctrl-enter` to newline `\n` in st-terminal? I need `ctrl-enter` to break newline. – Tuyen Pham Sep 27 '18 at 11:51
  • control+enter == enter (unless someone has an unusual configuration). It's your choice what to configure, and st is **not** configurable (must edit the program and compile). – Thomas Dickey Sep 27 '18 at 19:50