Basic Linux Tutorial
Computer Tutorial

Inserting and Deleting Text



Inserting and Deleting Text

Text insertion takes place only when you are in insert mode. Text deletion tasks are performed in command mode. When you use the i command to go to insert mode, new text is entered where the cursor is at the time you press the character i. When you insert new text, the previous text on the right-hand side of the cursor moves toward the right. If you use the a command to go to insert mode, the new text entry takes place after the current position of the cursor. You can use the I command to start entering new text at the beginning of a line and the A command to start entering at the end of a line.

list of text entry commands

Command Effect
i Start inserting text at the current cursor location.
I Start inserting text at the beginning of the current line.
a Start inserting text at the next character position relative to the current cursor location.
A Start inserting text at the end of the current line.
o Append a blank line just below the current line and start inserting text from the beginning of that line.
O Append a blank line just above the current line and start inserting text from the beginning of that line.
Command Effect
x Delete character at current cursor location.
nx Delete n characters starting at current cursor location.
X Delete previous character from the current cursor location.
nX Delete n previous characters from the current cursor location.
dd Delete current line.
db Delete previous word.
dw Delete from current cursor location to the end of word.
dG Delete to the end of file including current line.