ultisnips icon indicating copy to clipboard operation
ultisnips copied to clipboard

[Question] How to do multiple transformations at once?

Open mlysle opened this issue 3 years ago • 0 comments

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)?

mlysle avatar Oct 29 '20 21:10 mlysle