68

From GNU less manpage

-i or --ignore-case

Causes searches to ignore case; that is, uppercase and lowercase are considered identical.

This option is ignored if any uppercase letters appear in the search pattern; in other words, if a pattern contains uppercase letters, then that search does not ignore case.

-I or --IGNORE-CASE

Like -i, but searches ignore case even if the pattern contains uppercase letters.

This is a great way of searching in GNU less, while ignoring case sensitivity. However, you must know in advance that you'd like to search while ignoring case sensitivity and indicate it in the command line.

vim solves this problem by letting the user specify \c before a search, to indicate that the pattern should be searched while ignoring case sensitivity.

Is there a way to do the same in less (without specifying -I in the command line)?

Tom Feiner
  • 18,598

3 Answers3

94

You can set it from within less by typing -i and then doing the normal search procedure.
Have a look in the help for less by pressing h

Andy
  • 1,523
7

After turning on Ignore case in searches by pressing -i you'll have to supply a lower case search pattern to perform a case insensitive search. If the search pattern has upper case characters the search will still be case sensitive.

0

Piotr Gogolin and MrMas are correct -- even after you press -i, you still have to provide all lower case letters for it to search in a case-insensitive way.

However, if you press -I (with BIG I not little i), THEN when you do a search, you can type in all upper-case letters and it will still match lower-case strings. -I will give you "truly" case-insensitive search.