VI is the widely used text editor in UNIX operating systems. I have had the chance to use the VI editor in the Solaris and Linux operating systems. In this article we are going to learn how to use the VI editor.
Use u for undoing the last command. For undoing the last edit on the current line only, unless you move off the line you were editing. use U.
Tips: To perform the last change, use . (period once).
Copying and pasting: You can paste the content you deleted, since the deleted contents are kept in a buffer. Use p to paste. Use yy to copy the current line or use :y for copying (or yanking) the current line, and use yw to copy the buffer contents ("yw" for "yank work"). You can use yyp together to copy and paste the current line. Use p to put the buffer contents after the position or after the line. Use P to put the buffer contents before the position or before the line.
You can copy the content in different buffers from a to z, and you can also paste from these buffers by specifying the buffer before the paste command like (a-z)p or (a-z)P. Named buffers may be specified before any deletion, change, yank or put command. The general prefix has the form "c where c is any lowercase character. For example, "adw deletes a word into buffer a. It may thereafter be put back into text with an appropriate "ap.
Searching:Use / for searching in the forward direction and, use ? for searching in the backward direction. The following are some examples.
search down for "str" in forward direction
search up for "str" in backward direction
You can ignore cases during searching by using the set command.