Pattern matching with the vi editor

To learn about pattern matching, we will ensure that the pattern that we will search for is highlighted when the pattern searched for is found. The configuration file for vi is /etc/vimrc.In the vi editor, use the following commands for various options:

Sr. Commands Description
:set hlsearch
Highlights the search pattern
2 :se[t] showmode Shows when you are in insert mode
3 :se[t] ic Ignores case when searching
4 :set noic Shows a case-sensitive search


The user should open the file in vi, press the Esc button so that it enters command mode, and then type colon, followed by these commands. The following are the commands for pattern search and replace:

Sr. Commands Description

Get Learning Linux Shell Scripting - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.