[Solved] Documentation of the Code Snippet Variables

Developer
Dec 15, 2008 at 1:34 PM
Hi there,

I wanna ask if there is any documentation of the variables like $DropMarker$ of the Code Snippets.

For any suggestions im very thankful

best regards
Developer
Feb 12, 2009 at 1:26 PM
Hi again,

I really need to know which Marker is for what.

I found a little description in SnippetManager.cs but there are still some things I
don't know.

$DropMarker$ - ???
$Selection - Simply insert the selected text at this position
$Anchor$ - ???
$Caret$ - ???
$End$ - I guess this is the last mark of an snippet

And is there a way to define tokens by myself???

Thanks in advance
Coordinator
Feb 24, 2009 at 12:18 AM
Sorry, no documentation on the subject but I can at least answer these.

$DropMarker$ This inserts a drop marker into the document. This is a feature inspired by CodeRush. (look under Marker Heading)

$Anchor$ and $Caret$ both control where the selection is when the snippet expands. $Caret$ is of course the text caret, the blinking cursor. $Anchor$ controls where the beginning of the selection occurs. If $Anchor$ is at the same location as $Caret$ or is omitted, there will be no selection.

Custom Tokens:
Anything in the $token$ format that isn't one of the built in becomes a custom token. These work much in the way that Visual Studio Snippets work, only you don't have to specifically define them in xml. A good example is the "f" snippet in c# (for loop)

for (int $i$ = $0$; $i$ < $max$; $i$++)
{
    $selected$$end$
}$DropMarker$

So in addition to some built in tokens we have custom tokens $i$, $0$, and $max$. When the snippet expands you'll get this
for (int |i|=-; |i| < |max|; |i|++)
{
    ^
}^

Where || indicates boxed regions and ^ are markers (one red, one green). the first |i| will be selected and the box highlighted green marking it as active (as well as all the other |i|s. If you want to change the name of the variable, do so. Say "loopCounter". You'll notice as you type each of the other |i|s change with it. When you're done with changing |i| hit tab to go to the next token. Tab cycles through all of them in a loop. That brings us to...

$End$ marks the spot where the caret should go once you complete filling out the custom tokens. To mark complete make sure one of the token regions are active and hit enter. This un-highlights the regions and puts the caret at the $End$ location.
Developer
Mar 11, 2009 at 8:19 AM
Edited Mar 11, 2009 at 8:19 AM
Thanks Chris that helped me very much =)