0

I want to change this:

_(with(new FuListNode )->isList())->shouldBe(true);
_(with(new FuListNodes)->isList())->shouldBe(false);
_(with(new FuTreeNode )->isList())->shouldBe(true);
_(with(new FuTreeNodes)->isList())->shouldBe(false); } }

to this (look at the booleans at the end):

_(with(new FuListNode )->isList())->shouldBe(false);
_(with(new FuListNodes)->isList())->shouldBe(true);
_(with(new FuTreeNode )->isList())->shouldBe(false);
_(with(new FuTreeNodes)->isList())->shouldBe(true); } }

I'm using TextMate, how can I do that cleanly with a single find/replace?

Ollie Saunders
  • 7,787
  • 3
  • 29
  • 37
  • There are so many reasons why you might have said that, but out of curiosity, what it is that you find strange? – Ollie Saunders Oct 15 '09 at 02:37
  • A bunch of similar lines in source code. Can't you iterate over them with an array or something? – strager Oct 15 '09 at 02:48
  • Oh, OK. To me that's probably the worst thing you could have said. These are specs. Duplication of that kind is not damaging in specs. Iterating over these means that if one of them failed the spec failure message wouldn't tell me which one. – Ollie Saunders Oct 15 '09 at 02:56

3 Answers3

1

It can't be done using a single search and replace.

Bart Kiers
  • 166,582
  • 36
  • 299
  • 288
0

Can you do this?

s/true|false/!&/
strager
  • 88,763
  • 26
  • 134
  • 176
  • Then don't use TextMate...? Or find a plugin...? – mpen Oct 15 '09 at 05:52
  • I don’t know if the suggested replace works in `sed`, but if it does, can’t you simply filter the whole file through an external command? – zoul Oct 15 '09 at 06:16
0

I have never used TextMate but can you not do something like this ?

1. Replace all "true" with some dummy value, say "hello"
2. Replace all "false" with "true"
3. Replace all "hello" with "false"

Of course this involves 3 find-replaces and not 1 as you've requested.

Rahul
  • 12,886
  • 13
  • 57
  • 62
  • That's what I ended-up doing. Not ideal though. I have to do this kind of thing from time to time so I'd like a faster option. – Ollie Saunders Oct 15 '09 at 05:36