You can create a new VA Snippet using an existing fragment of code. You can initiate the creation in either of two ways.
Highlight a fragment, and then select VAssistX | Tools | Create VA Snippet from selection.
![](/~/media/wholetomato/kb/documentation/va-snippets-create-from-selection/vassistxtoolscreate.ashx?la=ru&hash=3186836B52DAFD1C9FBFE861DCF7E07CF90521CA)
Or, highlight a fragment; open VAssistX | Insert VA Snippet; and then select Create VA Snippet from selection.
![](/~/media/wholetomato/kb/documentation/va-snippets-create-from-selection/snippetcreatefromselectionmenu2.ashx?la=ru&hash=DB870E182D2426FF8476EE24E05DC58E4265802D)
The VA Snippet editor opens with your fragment in a new VA Snippet. Modify the VA Snippet as necessary, including updating of title and shortcut, and replacing of constants and symbol names with placeholders.
Example
Manage pointer types using the Resource-Acquisition-Is-Initialization (RAII) programming idiom and a VA Snippet. Select the following lines you might have for an existing pointer.
![](/~/media/wholetomato/kb/documentation/va-snippets-create-from-selection/snippetcreatedemoselection.ashx?la=ru&hash=ED660B686101D8DB768B598D4E2AACF8EE4753DD)
Select VAssistX | Insert VA Snippet | Create VA Snippet from selection...
The VA Snippet editor opens.
![](/~/media/wholetomato/kb/documentation/va-snippets-create-from-selection/snippetcreatedemoeditoropen.ashx?la=ru&hash=42482C3E602D3D47855B399ACAD247E7C40E9722)
Update title, shortcut, and description.
![](/~/media/wholetomato/kb/documentation/va-snippets-create-from-selection/snippetcreatedemoeditortitle.ashx?la=ru&hash=B1482B5CDEE46E250D74FD2BCC64AB4BA82BB493)
Replace symbol names in code with input placeholders: $name$ and $type$. Position caret after expansion with $end$.
![](/~/media/wholetomato/kb/documentation/va-snippets-create-from-selection/snippetcreatedemoeditorcode.ashx?la=ru&hash=1A0EF38AB99E3AE5801914D2F56C24AD4BB9EE78)
Exit the VA Snippet editor, saving your changes.
In the text editor, type your shortcut and accept the suggested VA Snippet.
![](/~/media/wholetomato/kb/documentation/va-snippets-create-from-selection/snippetcreatedemotry.ashx?la=ru&hash=B50154D5C8076F32DECB79C87F0F0EA89BF19463)
Enter a type and name in the dialog.
![](/~/media/wholetomato/kb/documentation/va-snippets-create-from-selection/snippetcreatedemotrydialog.ashx?la=ru&hash=889A6AA43EFC6054FBD0C2D809CECAA44A9DF1A2)
Accept the dialog and confirm VA Snippet expanded as you expected.
![](/~/media/wholetomato/kb/documentation/va-snippets-create-from-selection/snippetcreatedemotryexpanded.ashx?la=ru&hash=A5DAF73B8D1B7982F552EDB7F7B926D706FF97FF)