'UltiSnips shell/python interpolation and ${VISUAL}

I really can not figure how to do this.

I am trying to create a snippet that will read a file (the name I will get it by selecting it so it will be in the ${VISUAL}) and then using grep extract a line from it.

What I tried is something like

!v cat ${VISUAL}  | grep "some text"

but of course that in shell ${VISUAL} has a different value.

I tried something in python, but I am lost. All I could get was

!p snip.rv=snip.v.text

that will give me the value for ${VISUAL}

Thank you for your help.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source