In this article, we are going to see some of the most important settings which is mandatory for a developer to have in his .vimrc or .exrc file.
set incsearch : When we want to search for something in vi, we put a slash(/) and start typing the word in the escape mode. On finishing typing, and when we press enter, we get to know whether the word is present in the file or not. The setting ‘incsearch’ is a special feature in which you will know whether what you are typing is there or not in the file as you type it. As you keep tying, the matching contents keep getting highlighted. It is like in google search, we get to see the search results as we keep tying.
set smartindent – There is another feature called autoindent. What autoindent does it indents your newline with respect to the last line. Smartindent, as the name suggests, is really smart. It indents with respect to the programming constructs as well. For example, if you start writing a ‘if ‘block and open a brace and press enter, automatically it indents so that you can straightaway start typing in the new line.
set smartcase – By default, the search we do inside vi is case sensitive. However, this case sensitive feature is not always useful for us. Sometimes, we would be interested to find out something either in upper case of lower case. However, sometimes when we explicity search for something by giving a specific character in upper case, we would like to receive only those results. This is exactly what the smartcase does.
set hlsearch – This feature, highlights the search pattern with a specific color while being searched. It helps us in looking for the patterns faster. Also, we can choose the color in which we would like it to get highlighted.
hi Search ctermfg=Black ctermbg=Yellow cterm=Bold
set nowrapscan – When we search for a pattern, assume there are multiple matches available in the file, we can proceed to the next match by pressing “n”. Once the last pattern is reached, it automatically goes to the beginning of the file. Some people might prefer the search not to go ahead once it is reached the last pattern in the file(which is the case in many), this is the feature, nowrapscan, which will do it for you.