Sublime Forum

Unwanted behaviour of TAB after snippet

#1

Hello, I am using Sublime Text 3 with Mac OS X 10.11.
I have created some snippet to be used with latex. For instance I have created this snippet:

<snippet>
	<content><![CDATA[
\vert${1:}\vert
]]></content>
	<tabTrigger>vert</tabTrigger>
	<scope>text.tex.latex</scope>
</snippet>

I would like that if I type
vert, TAB, SPACE, vert TAB
I get
\vert \vert\vert\vert
with the cursor between the two central “\vert”. (NOTE: I have to type SPACE because otherwise I will be trying to trigger a snippet with the word vertvert and not vert).

The problem is that I get this
\vert vert\vert
with the cursor at the end. This because when I press TAB the second snipped does not trigger and the cursor move at the end of the last word created with the previous snippet. Anyone knows how to solve my problem?

Note: pressing TAB in order to go at the end of the snippet is generally useful, except when I need autocompletion inside a snippet, but since if I press CMD+Left Arrow the editing cursor goes at the end of the line I find useless to having multiple shortcuts for doing about the same thing and in a conflicting way!

0 Likes

[solved]Auto completion trigger stop after previous trigger completion in tex file
#2

You can do in two ways: press ESC or insert ${0:text}$.

0 Likes

#3

Using $0 is the easiest solution to this. Any number higher than 0 will cause ST to create a “tab field” that can be tabbed to and from, whereas the 0 field will always be the last. However, if you only have the 0 it will just go there and not create tab fields, so that you can not move there.

You could also use ctrl+space to manually trigger the auto-completion popup, which should list the snippet at the top.

1 Like