hello
Ruben Debeerst suggests to change the "left...right" snippet which wraps "(something)" into "\left(something\right)"
I think that is interesting but I would like to make this for ( and [ but not for {
In this case, I would prefer
"{something}" into "\left{something\right}"
But I've a problem because actually I learn regex, ruby syntax grammar etc....
I'm sure that's possible with a command and a script with ruby or perl but is it possible only with regex in a snippet.
The proposition of Ruben is :
${TM_SELECTED_TEXT/(.*)(\}|)|])/\left$1\right$2/}
If I make a special snippet for {
I have two snippets
for ( and [
${TM_SELECTED_TEXT/(.*)()|])/\left$1\right$2/}
and for {
${TM_SELECTED_TEXT/(.*)(})/\left\$1\right\$2/}
How to make this with only one snippet ?
Thanks
Regars Alain
Try this command (before: none, input: selection or nothing, output: replace selection):
#!/usr/bin/env ruby
sel = STDIN.read.chomp sel.match(/^(.+)(.)$/) left = $~[1] right = $~[2] print "\left#{left}\right#{right}"
Le 20 sept. 07 à 19:25, Ben Alpert a écrit :
Try this command (before: none, input: selection or nothing, output: replace selection):
#!/usr/bin/env ruby
sel = STDIN.read.chomp sel.match(/^(.+)(.)$/) left = $~[1] right = $~[2] print "\left#{left}\right#{right}"
bravo ! fine
Compliments from Paris
Regards Alain PS : I need to learn Ruby !!
Le 20 sept. 07 à 19:25, Ben Alpert a écrit :
Try this command (before: none, input: selection or nothing, output: replace selection):
#!/usr/bin/env ruby
sel = STDIN.read.chomp sel.match(/^(.+)(.)$/) left = $~[1] right = $~[2] print "\left#{left}\right#{right}"
hello Ben
How to make a test like :
if right = } then right =\right
Thanks and Regards
Alain
Le 21 sept. 07 à 09:30, Alain Matthes a écrit :
hello Ben
How to make a test like :
if right = } then right =\right
I found :
#!/usr/bin/env ruby
sel = STDIN.read.chomp sel.match(/^(.+)(.)$/) left = $~[1] right = $~[2] if right == '}' left = '\{' right = '\}' end print "\left#{left}\right#{right}"
Regards Alain