Although there is no specific syntax for aliases you can achieve the same effect by using post_jump
:
# c.snippets
global !p
def expand(snip):
if snip.tabstop != 1:
return
vim.eval('feedkeys("\<C-R>=UltiSnips#ExpandSnippet()\<CR>")')
endglobal
snippet incstdlib "#include <stdlib.h>" !b
#include <stdlib.h> /* exit(), malloc(), free() */
$0
endsnippet
post_jump "expand(snip)"
snippet incexit "#include <stdlib.h>" !b
incstdlib$1
endsnippet
In this snippets file the trigger incexit
is an "alias" of trigger incstdlib
. In reality incexit
expands to incstdlib
and the expand(snip)
is called when UltiSnips moves to the tabstop $1
. The expand(snip)
just executes the VimScript function UltiSnips#ExpandSnippet
which will expand incstdlib
into it's final expanded form #include <stdlib.h>
.
Another options is to use UltiSnips regular expression support instead:
snippet "inc(true|false|bool)" "#include <stdbool.h>" r
#include <stdbool.h> /* true, false */
endsnippet
Here you will have three triggers inctrue
, incfalse
and incbool
that are effectively the same. The only drawback is that autocompletion plugins like YouCompleteMe will not autocomplete those.
plugin-ultisnips
, so I would assume the OP is using ultisnips.neosnippet
plugin, its syntax has analias
keyword for this very purpose.