I want to make a snippet which only triggers after a >
symbol, that way if I'm inside a (x<cursor>)
, and I hit tab it won't trigger, but if it's after an html tag like <div>x<cursor>
it will trigger.
Asked
Active
Viewed 295 times
1 Answers
1
You could use an insert-mode map:
inoremap > ><c-o>:echoe "inside tag"<cr>
inoremap < <<c-o>:echoe "outside tag"<cr>
replace echoe
with the function or command you want to trigger inside html tags.
Edit:
inoremap > ><c-o>:silent! iunmap <c-v><tab<c-v>><cr>
inoremap < <<c-o>:silent! imap <c-v><tab<c-v>> <Plug>SuperTabForward<cr>
If you have SuperTab plugin this should work. The first command disables tag completion when typing >. The second command renables tab completion when typing <.

builder-7000
- 7,131
- 3
- 19
- 43
-
Sorry I should have been more clear, I want the tab completion letter to be `x` but I dont want it to expand if its preceeded by a `>` character. That way if I'm putting `(x)` in a argument it wont expand when I hit tab, but when I do `x` it will– Tallboy Apr 06 '18 at 01:41
-
1Hmm.. I appreciate the answer but I'd rather just do it right inside of the Ultisnips plugin (I gave you an upvote tho!). I have about 50 expansions that I want to use this for. It looks like I can do it with a 'trigger' regex but I can't find any examples of how to actually do that. – Tallboy Apr 06 '18 at 05:47
-
I guess the best way to taggle this problem in UltiSnips itself is with a context-sensitive snippet (see section 4.9 of the docs). A context can be any python expression that evaluates to true/false. So write an expression that compares the number of opening < and closing > and let your snippet only trigger if they even out. – wataya Apr 08 '18 at 11:22