atom / find-and-replace

Find and replace in a single buffer and in the project
MIT License
242 stars 219 forks source link

Find Whole Word in PHP code does not find variables with preceding $ sign #1121

Closed aurovrata closed 4 years ago

aurovrata commented 4 years ago

the search is able to find variables start with the word, for example searching for $valid will find

$valid $validation (highlights only $valid part of the word) $validted (highlights only `$valid part of the word)

however, when toggling the 'whole word` option, it finds no match.

I have to use the 'regex' mode and search for '\$valid ' with a space after it.

Arcanemagus commented 4 years ago

What constitutes a "whole word" is defined by the language, in this case the PHP language doesn't consider the $ as part of the "word characters", thus you can't use whole word to search for that.

aurovrata commented 4 years ago

hahaha, that's a rather lame reply. Are you just too busy to fix this or are you genuinely being lame?

If one cannot search and replace variables in a PHP code then what's the purpose of the functionality in the first place?

zmorris commented 3 years ago

This issue was reported almost 6 years ago but I think the Atom maintainers are struggling to put out these fires. Here is the technique I'm using until they get around to it: https://github.com/atom/find-and-replace/issues/1121

Enable the .* regex option. Disable the whole word option.

\$variable\b

Basically surround the search in \ and add b on the end. It works well enough I guess.

aurovrata commented 3 years ago

Unfortunately @Arcanemagus dismissed this as a non-issue and closed it. So it will never get fixed. Time to look for another IDE?