Changing text involves the substitution of one section of text for another. vi has several ways to do this, depending on circumstances.
To replace a word, position the cursor at the beginning of the word to be replaced. Type cw, followed by the new word. To finish, press Esc.
To change part of a word, place the cursor on the word, to the right of the portion to be saved. Type cw, type the correction, and press Esc.
To replace a line, position the cursor anywhere on the line and type cc. The line disappears, leaving a blank line for your new text (which can be of any length). Press Esc to finish.
To substitute one or more characters for the character under the cursor, type s, followed by the new text. Press Esc to return to command mode.
Use this command to replace the character highlighted by the cursor with another character. Position the cursor over the character and type r, followed by just one replacement character. After the substitution, vi automatically returns to command mode (you do not need to press Esc).