The syntax of UltiSnips's snippet is as below:

snippet trigger_word [ "description" [ options ] ]

The upper method can convert all characters in the string into upper case:


I want to write a small snippets to convert the trigger_word into it's upper case in html file.Add the below lines in vim-snippets/UltiSnips\html.snippets.

snippet string
`!p snip.rv="string".upper()`

string can expand into STRING when to edit html file,how can make any other string be expanded into it's uppercase status?For example,otherstring expanded into OTHERSTRING?If i get the way to get trigger_word as a variable ,then it's simple to convert in calling python.

1 Answer 1


From the question it seems that a generic trigger is preferred. If so, a regex snippet would be useful here. The following changes {somestring}.upper to {SOMESTRING}:

snippet "(\w+)\.upper" "make upper" r
`!p snip.rv=match.group(1).upper()`

The r flag makes it a regex snippet, whose regex trigger is enclosed in quotes ("(\w+)\.upper"). (Note that python regex is used, and not vim regex.) The main string to be accessed is in (\w+), which is the first captured group as part of the regex (match.group(1)). Finally, this is returned in its uppercase form.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.