As you are reading this article, it is obvious, you are using Linux as your operating system. If you are a programmer, you mostly using Vi/Vim as your coding playground.
Vim is the simple text editor with a powerful bundle of features for coding. From highlighting the syntax in Vi/Vim editor to auto-completion of the variable names. Vi/Vim has all that. But, very few of us know these features.
Because of not having a better UI interface, many of the programmers are not aware of these features. Linux is known for its powerful set of commands and so the Vim editor.
Before making Vim case-insensitive search, let’s start learning from the beginning to search the text in Vim editor file.
You have written long programming code and now you want to search all the occurrences of the particular variable.
vim textFile
:
and enter the term you want to search.:<string_to_be_search>
Example:
:strName
This will highlight all the occurrences of variable name strName.
This is case sensitive search. So it will not highlight “strname” or “STRNAME” or all other variants of upper and lower case characters.
You can use set
command for case sensitive search in vim editor.
Follow the steps given below.
vim textFile
ctrl+c
set
command for case-insensitive search:set ignorecase
This command is easy to remember as it sounds “ignore case” which is more meaningful here.
:<string_to_be_search>
Example:
:strName
What if you want to go back to case-sensitive search?
You can enable the case-sensitive search again with a simple command.
:set noignorecase
Now, every time you search in Vim, it will be case-sensitive search.
This is all from this simple set
command that helps you for Vim case-insensitive search.
Do you want to know my favorite editor? You can read all the different editors I personally use for different projects and OS.
I have tested all the commands on my Ubuntu Linux system.
For more such simple and powerful Linux commands, stay tuned.
If I have enabled case insensitive search and now I want to go back to case sensitive search?
How to revert the changes?
Thanks for posting your query. I missed covering that.
You can use the following command to enable case-sensitive search.
:set noignorecase
PS: Updated post