How do you do a case insensitive search using a pattern modifier using less?

前端 未结 5 985
清酒与你
清酒与你 2021-01-29 18:27

It seems like the only way to do this is to pass the -i parameter in when you initially run less. Does anyone know of some secret hack to make something like this work



        
5条回答
  •  爱一瞬间的悲伤
    2021-01-29 19:13

    It appears that you can summon this feature on a per search basis like so:

    less prompt> /search string/-i
    

    This option is in less's interactive help which you access via h:

    less prompt> h
    ...
      -i  ........  --ignore-case
                      Ignore case in searches that do not contain uppercase.
      -I  ........  --IGNORE-CASE
                      Ignore case in all searches.
    ...
    

    I've not extensively checked but the help in less version 487 on MacOS as well as other Linux distros lists this option as being available.

    On MacOS you can also install a newer version of less via brew:

    $ brew install less
    $ less --version
    less 530 (POSIX regular expressions)
    Copyright (C) 1984-2017  Mark Nudelman
    

    References

    • less is always case-insensitive

提交回复
热议问题