[TxMt] Re: Replace all matches with Regex substitution in Snippets
Rob McBroom
mailinglist0 at skurfer.com
Mon Feb 14 13:36:43 UTC 2011
On Feb 14, 2011, at 2:07 AM, Brandon M Fryslie wrote:
> I am using the ${1/foo/bar} syntax to make a snippet. More specifically I am mirroring/transforming a previous placeholder to replace all spaces with underscores like this: ${1/ /_/}.
>
> However, is this only replaces the first occurrence. Could anyone enlighten me to the correct way to do this? Also, is there some documentation to the 'options' parameter in the regex replacement syntax? I couldn't seem to find any under regex or snippets on the TextMate site.
I don’t know if this works in TextMate specifically, but in many other contexts, adding a ‘g’ (for global) will indicate that all occurrences on the line should be replaced instead of just the first one. Try ${1/ /_/g}.
--
Rob McBroom
<http://www.skurfer.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20110214/463ebfc3/attachment.html>
More information about the textmate
mailing list