SirVer / ultisnips

UltiSnips - The ultimate snippet solution for Vim. Send pull requests to SirVer/ultisnips!
GNU General Public License v3.0
7.55k stars 691 forks source link

Is there any way to forcefully remove the current snippet status? #1549

Closed xvzc closed 11 months ago

xvzc commented 11 months ago

When i expand snippet and leave the insert mode before i jump forward to ${0}, the place holder still remains so that CanJumpForward() returns 1. My current configuration is like below.

let g:UltiSnipsExpandTrigger="<Nop>"
let g:UltiSnipsJumpForwardTrigger="<Nop>"
let g:UltiSnipsJumpBackwardTrigger="<Nop>"

inoremap <silent><expr><nowait> <Tab>
\ UltiSnips#CanJumpForwards() ? "\<C-r>=UltiSnips#JumpForwards()\<CR>" :
\ UltiSnips#CanExpandSnippet() ? "\<C-r>=UltiSnips#ExpandSnippet()\<CR>" :
\ "\<Tab>"

snoremap <buffer><silent><nowait> <Tab> <Esc>:call UltiSnips#JumpForwards()<CR>

inoremap <silent><expr><nowait> <S-Tab>
\ UltiSnips#CanJumpBackwards() ? "\<C-r>=UltiSnips#JumpBackwards()\<CR>" :
\ "\<C-d>"

snoremap <buffer><silent><nowait> <S-Tab> <Esc>:call UltiSnips#JumpBackwards()<CR>

Expected behavior:

snippet fori
for (int ${1:i} = ${2:0}; $3; ${4:++}$1) {
    ${0}
}
endsnippet
  1. Leave insert mode at ${2}
  2. Go back into insert mode
  3. Press <Tab>
  4. It should insert char

Actual behavior:

snippet fori
for (int ${1:i} = ${2:0}; $3; ${4:++}$1) {
    ${0}
}
endsnippet
  1. Leave insert mode at ${2}
  2. Go back into insert mode
  3. Press <Tab>
  4. It jumps to the next placeholder ${3}

Steps to reproduce


xvzc commented 11 months ago

Solved