next up previous
Next: RE in sed: Up: Programs Using Regular Expressions Previous: Grep and Egrep

RE in vi:

Another application which uses REs is the vi editor. For purpose of an exercise we will create a file 'temp' in the current directory. Open a file by typing:
vi temp
and enter the following two lines:
Tooting and froing
until tomorrow morning

Now suppose we want to search for a string starting with 't' and ending with 'ing'. The correct regular expression is: t.*ing
Switch into the command mode by pressing
ESC
and type
/t.*ing $($ENTER$)$. The cursor will point to the first character of the longest match 'ting and froing'.
Press
/ $($ ENTER$)$ and the cursor will move to the next match: 'til tomorrow morning'.

For more options refer to the UNIX in a nutshell book.



Instructional Support Group 2008-08-05