Find the answer to your Linux question:
Results 1 to 7 of 7
How do I do case insensitive search for a regexp ? So I'm looking for commands like / or ? but the matching should be case insensitive....
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575

    Question about vi


    How do I do case insensitive search for a regexp ? So I'm looking for commands like
    / or ? but the matching should be case insensitive.

  2. #2
    Linux Engineer rong's Avatar
    Join Date
    Feb 2005
    Location
    California
    Posts
    803

    Re: Question about vi

    Quote Originally Posted by Santa's little helper
    How do I do case insensitive search for a regexp ? So I'm looking for commands like
    / or ? but the matching should be case insensitive.
    I found this so maybe it'll help?? vi search
    registered Linux user #388382

    Have you checked here first?

  3. #3
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575
    As far as I can see it doesn't have the information I want.But thanks for the effort.

  4. #4
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    Are you trying to find a regexp in your file based on a search term? If that is the case, then do:

    Code:
    :set ignorecase
    This will make searches case insensitive.

    The other option is to use:

    Code:
    :set ignorecase smartcase
    This will, if your search term includes no uppercase letters, do a case-insensitive search. If there is an uppercase letter, then the search becomes case-sensitive. So, for example:

    bob --> bob, Bob, BOb, BOB, etc.
    boB --> boB
    BoB --> BoB

    And so on.


    If you mean that you're trying to search through your file with a regular expression (as in, the search term is a regexp), I found a tutorial which may help at:

    http://www.geocities.com/volontir/

  5. #5
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575
    :set ignorecase was what I was looking for.Thanks a lot.

  6. #6
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575
    Come to think of it I have another question: is there a way to do a search
    where every character will be interpreted literally ? So for example * will
    not mean match 0 or more of something but it will mean a literal *

    One way of course is to escape every special character but what I'm looking for
    is some option which if set will mean that every character will be interpreted
    literally without escaping anything.

  7. #7
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575
    Yes there is: you use :set nomagic
    I find the name of the option (magic) rather amusing too.

    Ok , I have another one.Let's say I'm typing some text where
    I plan to use some long word , for example "installation" , a lot.
    Is there a way to make it so that by pressing a single button , f1 for
    example , the whole word gets printed ?

    If you know the answer to this one , even for (x)emacs please share.

    By the way , as I found out , instead of writing :set ignorecase you can simply write :set ic

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •