An introduction to 'vi' Editor

vi editor (Visual Editor) is a default editor comes with most of UNIX operating system. vi editor had two modes:
1. Command mode - cause action to be taken on the file. Once file is opened, you are in command mode.
2. Insert mode - entered text is inserted into the file.

Some commands:
Starting vi and saving file:
To use vi on a file, type in vi filename. If the file named filename exists, then the first page (or screen) of the file will be displayed; if the file does not exist, then an empty file and screen are created into which you may enter text
vi filename - start editing filename, create it if necessary. Usually the new or modified file is saved when you leave vi. However, it is also possible to quit vi without saving the file.
:wq - Write the file (save) and Quit.
:q! - quit without saving any changes.
:w! newfile - write all lines from the entire current file into the file 'newfile', overwriting any existing newfile.
:n,m w! newfile - write the lines from n to m, inclusive, into the file newfile, overwriting any existing newfile

Moving the Cursor :
h - one space left/also try left arrow)
j - one line down (also try down arrow)
k - one line up (also try up arrow)
l - one space to the right (also try right arrow)
$ - end of current line
^ - beginning of current line.
Enter - beginning first word on the next line.
G - end of file.
:n - line n; use :0 to move the beginning of the file .
w - beginning of next word; 5w moves to the beginning of the 5th word to the right .
e - end of next word
b - beginning of previous word
Ctrl-b - one page up
Ctrl-f - one page down
% - the matching (, ), [, ], {, or } (Press % with your cursor on one of these characters to move your cursor its mate.)

Searching for Text :
/string - search down for string.
?string - search up for string.
n - repeat last search from present position

Inserting Text:
a - append starting right of cursor
A - append at the end of the current line
i - insert starting left of cursor
I - insert at beginning of the current line
o - open line below cursor, then enter insert mode
O - open line above cursor, then enter insert mode
:r newfile - add the contents of the file newfile starting below the current lin

Deleting Text :
x - delete single character; 5x deletes 5 characters
dw - delete word; 5dw deletes 5 words
dd - delete line; 5dd deletes ... well you get the idea!
cw - delete word, leaves you in insert mode (i.e. change word)
cc - change line -- delete line and start insert mode
s - change character -- delete character and start insert mode
D - delete from cursor to end of line
C - change from cursor to end of line -- delete and start insert mode
u - undo last change
U - undo all changes to current line
J - join current line with line that follows (press Enter in insert mode to split line)

Cutting and Pasting:
xp - transpose two characters (two commands, x followed by p)
yy - yank (i.e. copy) one line into a general buffer (5yy to yank 5 lines)
"ayy - yank into the buffer named a
P - put the general buffer back before the current line
"aP - put from buffer a before current line
p - put the general buffer back after the current line
"ap- put from buffer a after the current line
While there are a number of vi commands, just a handful of these is usually sufficient for a QA Tester/Engineer. Lets focus on some commands that is useful for a tester's daily use.

cat
to open a text file for viewing