[TxMt] REQUEST: Scope-based Find/Replace
Thomas Aylott - subtleGradient
textmate at subtleGradient.com
Sun Mar 30 17:48:07 UTC 2008
On Mar 29, 2008, at 10:37 PM, Alain O'Dea wrote:
> I would find it incredibly useful if I could do a Find/Replace such
> that I could reliably rename symbols like variables and function
> names. I envision that this would be based on scopes and that it
> would constrain Find/Replace to exact matches of entire scopes. In
> Erlang this would enable me to rename variables by doing a Find/
> Replace of exact scope match for variable.other.erlang.
Actually, search and replace is more powerful than the scope matching
in language grammars.
Find and replace regex can match multiple lines.
What you could do is look at the language definition file and find out
the regex that's used to scope variables and then modify it to search
and replace the specific variables you're looking for.
Maybe this could be automated in a command somehow. But, currently
TextMate wouldn't be able to do what you're asking in any but the
currently open document, since it doesn't even parse any files that it
doesn't have open, and a command isn't capable of accessing the parsed
version of any but the frontmost document anyway.
Maybe you could do something with a ruby script that parses all the
files in the project or something similar and asks you what variables
you want to replace.
Personally, I wouldn't touch something like this because of the pain
that it would take to debug it.
More information about the textmate
mailing list