ultisnips
ultisnips copied to clipboard
[Question] How to do multiple transformations at once?
I want to perform two transformations at once. The first transformation substitutes any spaces for underscores. Easy enough:
snippet p "Insert Link (substitute spaces)"
[${1:${VISUAL}}](./${1/ /_/g})$0
endsnippet
So typing p<TAB>hello world becomes into [hello world](hello_world)
The next substitution adds a leading ./ like so:
snippet p "Insert link (add a leading ./)"
[${1:${VISUAL}}](${1/(^.+)/\.\/$1/})$0
endsnippet
So typing p<TAB>bla becomes [bla](./bla)
So my question is how do I use both of these transformations together such that typing p<TAB>hello world becomes [hello world](./hello_world)
?