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 |
1 |
: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 |
1 | /pat | This searches for the pattern pat and places the cursor where the pattern occurs |
2 | / | This repeats the last search |
3 | :%s/old/new/g | Globally... |