I'm writing an XML document where I frequently produce markup like this:We can exit Terminal mode by pressing <keystroke>&lt;C-\&gt;&lt;C-n&gt;</keystroke>.I'd like to define an UltiSnips snippet to help with producing <keystroke> tags like this.Ideally, I'd be able to type (where <tab> expands the snippet, and <C-j> jumps to the next tabstop):keystroke<tab><C-\><C-n><C-j>and have it output:<keystroke>&lt;C-\&gt;&lt;C-n&gt;</keystroke>Is it possible to create a snippet for UltiSnips that behaves this way?
Make UltiSnips perform XML encoding on tabstop text
plugin ultisnips;filetype xml
Using regular expression snippet it's possible to achieve this. Following snippet works almost ideally:snippet keystroke([^>]\S+)? Adds keystroke r<keystroke>`!p snip.rv = (match.group(1) or ).replace(<, &lt;).replace(>, &gt;)`</keystroke>$0endsnippetIt works after you enter all the key sequences, for example: keystroke<C-\><C-n>Tab will result in:<keystroke>&lt;C-\&gt;&lt;C-n&gt;</keystroke>with the cursor position after </keystroke>