New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search: Please clarify documentation about case-insensitivity #406
Comments
Added to man page in 5d2bd5d. |
If a basic description of search cannot be documented in Thank you very much for the change, which is already a huge improvement. However, I think suggesting (only) Although this exceeds this ticket's scope, I cannot refrain from commenting that making Finally, while this goes beyond this ticket's scope once again, I shall note that if documentation cannot be as clear as possible about search being case-sensitive by default, then at least behavior could be improved; rather than displaying "Pattern not found" when no case-sensitive match is found, the bottom line could display something like:
or
I would be willing to bet this would suffice to prevent many person-days of lost productivity every calendar year (which visibly even affects some software professionals who have been relying on less for more than 0x10 years). |
Yeah, if I were to do it over again I probably wouldn't design the -i and -I options that way. But it's too late to change their behavior now. I'll think about the "Pattern not found" messaging. I wouldn't want to do both a case-sensitive and a case-insensitive match on every search just in case there's a match in the non-selected one, which could double the amount of time it takes to do a search. But maybe the messaging could be improved. |
After consideration, I don't think it's appropriate to complicate the "Pattern not found" message with a potentially misleading claim that the pattern might be found if you search again with different case sensitivity. I'm not aware of any other tool that does this: vi does not, vim does not, grep does not, and ack does not. |
Thank you @gwsw that is a valuable point. That being said, modern viewers search case-insensitively by default. Doing such a comparison will find ancient references. I don't think doing a case-insensitive search and a case-sensitive search would likely take twice the time as just a case-insensitive search. A case-sensitive search could just search the matches of the case-insensitive search. But multithreading allows considering both clarity and performance. Rather than displaying "Pattern not found" when no case-sensitive match is found, the bottom line could display something like:
...until a second, case-insensitive search completes. After completion, the message can be updated to either:
or
|
My 2c on this bikeshed color, is that the existing -i/-I quick help at the help page are generally enough as they clearly imply what the default is, and inform how to change it. The addition at the manpage is very good as well IMHO. I don't think mentioning sensitivity at the "not found" message is a common or good solution. So the only thing maybe missing is that at the help page, to make it more friendly, mention the default at the search section, and/or refer to -i/-I also at the search section of the help page, maybe something like "Use -i/-I to change case-sensitivity", or "Case-sensitive by default, see -i/-I". But personally I found the -i/-I help anyway (and FWIW, I use -i by default). |
It occurs to me that these suggestions don't fully address the issue. Suppose a file has "abc" on line 100, "ABC" on line 200, and "abc" on line 300. If the user does a case sensitive search for "abc" while under the erroneous impression that the search was case insensitive, they will find the first and third lines, but none of the above suggestions will alert them to the fact that they missed the second one. |
Right, I suggested changing the message to improve the behavior by making sure the message does not mislead the user. But the user may not even read the message, in which case his assumption would remain. Note that the message when there is no more match is simply "Pattern not found" whether the file contains a match or not. So the approach I suggested helps regardless of the number of matches in the file. |
The section about the main search command in
less
590's manpage contains:As for help, its section on search contains:
Unfortunately, none of this explains:
#2 is only explained in the documentation of the
-i
option (which implies #1):This is particularly hard to find as this does not use the term "sensitivity" or any term matching "sensitiv*".
I recommend to mention case-sensitivity in both help and the manual's part about
/
.The text was updated successfully, but these errors were encountered: