3

Whenever I hit Enter in insert mode, nothing happens, which is quite annoying as you can probably imagine.

I've checked the mapping with :imap and it turns out UltiSnips maps <CR>:

i  <CR>        * <C-R>=UltiSnips#ExpandSnippetOrJump()<CR>

If i iunmap <CR>, my enter key starts working again but UltiSnips stops working (which makes sense I guess).

I'm not using any premade snippets and I have a single tex.snippets file working. I have tried deleting everything from the file to check if something is wrong with my snippet definitions.

This behaviour will occur for all filetypes.

Here is my UltiSnips config:

let g:UltiSnipsSnippetsDir         = '~/.vim/ultisnips'
let g:UltiSnipsSnippetDirectories  = [$HOME.'/.vim/ultisnips']

let g:UltiSnipsExpandTrigger       = '<C-m>'
let g:UltiSnipsJumpForwardTrigger  = '<C-m>'
let g:UltiSnipsJumpBackwardTrigger = '<C-n>'

let g:UltiSnipsEditSplit           = "vertical"

Why does UltiSnips map <CR> for its function?

Thankful for any help with this since this makes UltiSnips unusable for me.

Anni
  • 33
  • 1
  • 3

1 Answers1

3

That's because <CTRL-M> is same as <CR> (Enter), see :help keycodes

notation    meaning         equivalent  decimal value(s)    ~
-----------------------------------------------------------------------
...
<Tab>       tab             CTRL-I      9   *tab* *Tab*
                                            *linefeed*
...
<CR>        carriage return CTRL-M      13  *carriage-return*
<Return>    same as <CR>                    *<Return>*
<Enter>     same as <CR>                    *<Enter>*
<Esc>       escape          CTRL-[      27  *escape* *<Esc>*
...

Similarly, for example CTRL-I means tab of Ctrl-[ means Esc. So you actually have configured it this way - let g:UltiSnipsExpandTrigger = '<C-m>'.

Borys Serebrov
  • 15,636
  • 2
  • 38
  • 54
  • Thanks so much, I don't think I'd have caught this! Makes UltiSnips usable for me again. – Anni Jan 18 '18 at 07:17