Hey guys,
I want to suggest to change the "left...right" snippet, which wraps "(something)" into "\left(something\right)". Right now the snippet catches any trailing caracter, but commonly it will only be used with brackets. I wanted to wrap "{something}" into "\left{something\right}". So I changed the snippet to
${TM_SELECTED_TEXT/(.*)(\}|)|])/\left$1\right$2/}
Maybe this is interesting for others and could be integrated into the bundle.
regards,
Ruben
Le 19 sept. 07 à 18:22, Ruben Debeerst a écrit :
${TM_SELECTED_TEXT/(.*)(\}|)|])/\left$1\right$2/}
yes it's fine
"(something)" into "\left(something\right)" fine "[something]" into "\left[something\right]" fine
but I will prefer
"{something}" into "\left{something\right}" but I don't know how to make a conditional insertion (there is a example in the doc but not very clear)
Is it possible to make this ? it is better because we can select exactly {something} with "shift cmd B" and not {.....}
Regards Alain
On 2007-09-19 19:25:58 +0200, Alain Matthes alain.matthes@mac.com said:
but I will prefer
"{something}" into "\left{something\right}" but I don't know how to make a conditional insertion
Yeah, I don't know how to do conditionals in snippets either. But you could make another snippet with ${TM_SELECTED_TEXT/{(.*)}/\left\{$1\right\}/}
Regards, Ruben
Le 2 oct. 07 à 09:12, Ruben Debeerst a écrit :
On 2007-09-19 19:25:58 +0200, Alain Matthes alain.matthes@mac.com said:
but I will prefer "{something}" into "\left{something\right}" but I don't know how to make a conditional insertion
Yeah, I don't know how to do conditionals in snippets either. But you could make another snippet with ${TM_SELECTED_TEXT/{(.*)}/\left\{$1\right\}/}
yes firstly i made this but the next command is useful :
#!/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
The command you posted didn't work for me. It didn't copy the selected text.
Try this one: #!/usr/bin/env ruby sel = STDIN.read.chomp if ( sel =~ /^\?{(.+)\?}$/) print "\left\{#{$1}\right\}"; elsif ( sel =~ /^(.)(.+)(.)$/) print "\left#{$1}#{$2}\right#{$3}"; end
It will do {abc} -> \left{abc\right} {abc} -> \left{abc\right} and [abc] -> \left[abc\right] where in the latter case also other characters than [ ] will work.
Ruben
Le 2 oct. 07 à 15:00, Ruben Debeerst a écrit :
The command you posted didn't work for me. It didn't copy the selected text.
yes with only {text}
Try this one: #!/usr/bin/env ruby sel = STDIN.read.chomp if ( sel =~ /^\?{(.+)\?}$/) print "\left\{#{$1}\right\}"; elsif ( sel =~ /^(.)(.+)(.)$/) print "\left#{$1}#{$2}\right#{$3}"; end
It will do {abc} -> \left{abc\right} {abc} -> \left{abc\right} and [abc] -> \left[abc\right] where in the latter case also other characters than [ ] will work.
Sorry, I don't send the good one :
#!/usr/bin/env ruby
sel = STDIN.read.chomp sel.match(/^(.+)(.)$/) left = $~[1] right = $~[2] if right == '}' left = '\'+$~[1] right = '\}' end print "\left#{left}\right#{right}"
Regards Alain