Is there any possible way to do expand trigger in UltiSnips with enter? I've tried <Enter>, <Return>, and <CR>. It works to trigger but doesn't work for new line. And I've tried to <S-Enter>, but vim doesn't seems like recognize that I press Shift button.

1 Answer 1


Apparently Ultisnips only does this for tab as early adopters of the plugin complained that it broke supertab. It's worth asking the maintainer whether he'd be willing to fix this for <CR> too.

That being said, there is a workaround that's described in the docs:

let g:ulti_expand_or_jump_res = 0 "default value, just set once
function! Ulti_ExpandOrJump_and_getRes()
    call UltiSnips#ExpandSnippetOrJump()
    return g:ulti_expand_or_jump_res

inoremap <CR> <C-R>=(Ulti_ExpandOrJump_and_getRes() > 0)?"":"\n"<CR>

Note that you probably don't want to use <CR> as your jump shortcut, as this would prevent you from filling in parts of a snippet with multi-line strings.

  • Works well but inserts two newlines when I hit enter. inoremap <CR> <C-R>=(Ulti_ExpandOrJump_and_getRes() > 0)?"":""<CR> seems to fix that
    – Hritik
    Feb 29, 2020 at 12:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.