• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • How to do a case sensitive search inside vi editor in Linux

    VI editor can sometimes be very tricky and irritating if you are not fully aware of those small arguments which could make your life much easier while working on the editor. One such thing when are trying to search a string and you want the search to be case sensitive.

    Let me tell you some special arguments which can be used for this purpose

    How to search a string in vi editor?

    • Exit the editing mode i.e. INSERT mode by pressing "Esc" from your keyboard
    • Then press Forward Slash "/"
    • Next type the string you want to search which should appear at the lower left bottom of the editor
    • Hit Enter

    If the searched string exists in the file, then it would be  highlighted  in some color.

    To perform a Case sensitive search

    Using the above method the search is normal and not case sensitive so there is a probability that you might miss out any word with a different case. To make sure you get everything as required follow the below steps

    • Press "Esc" to exit the INSERT mode
    • Then type ":set smartcase"

    Now if you search for "The" string then you will get all the words having "The" with capital "T" and others would be skipped i.e. "the".

    To remove a case sensitive search

    • Press "Esc" to exit the INSERT mode.
    • Then type ":set ignorecase"

    Using this if you search "THE", then all the words ir-respective of their case would be highlighted

    You can also use ":set ic" to set ignore space and ":set noic" to set smartcase.

    NOTE: Once all the search strings are highlighted you can go the next matched word by pressing "n" and in case you want to search backward then press "N". To go the first search in the file press "ggn"

    I hope this article was useful.

    Related Articles:
    10 practical examples to use USERADD command in linux
    10 Practical Examples for using FIND Command in Linux
    10 examples to help you understand top command usage in Unix/Linux
    15 tips to enhance security of your Linux machine

    How to do a case sensitive search inside vi editor in Linux How to do a case sensitive search inside vi editor in Linux Reviewed by admin on Monday, September 29, 2014 Rating: 5

    No comments:

    Powered by Blogger.