Hacker News new | ask | show | jobs
by thethirdone 2630 days ago
> but I never want to be in a place where I have to regex my code...ever).

I use regex search and replace fairly often; why are you so opposed to it?

If I need to change $t1 into t1 in a group of 6 lines (something I did today), its pretty easy to just make that replacement automatically. Doing it by hand would just take longer.

> ... with an occasional refactoring

That's exactly what I use the feature for.

1 comments

In a refactoring IDE, you never risk overmatching or under-scoping. You just rename the syntactic object and it's renamed exactly where it needs to be, including possibly on the filesystem and in git.
Importantly, you don't get that safety in comments or strings.

The nice thing about replacing via vim is that you can restrict it to a selected block which also gives you a type of safety.

Particularly for the situation I used replacement today, an IDE couldn't make it better and doing it only on a range was helpful.

Fair enough. An IDE will generally present you with matching strings on a project level and let you select which ones to change. But if you know where to look, replace within selection seems useful. Apparently IntelliJ supports that, but I've never thought to use it.