Appending text in VIM text editor

Unix

How to append text at the end of a line in vim?

To append any text at the end of a line we first have to switch to the command mode. For this we press the Escape [Esc] key. Next we move to the desired line using the nG command where n is an integer value denoting the line number were we want to move our cursor. For instance if we want to move to the 4th line we will type 4G and press enter. After reaching to the desired line we will hit the A and it will move the cursor to the end of the line and enter the INSERT mode were we can append our text.

Keys used

Press Escape [Esc] to enter command mode
Type nG to go to the nth line in the file where we want to append the text
Press A to move to the end of the desired line and enter into INSERT mode to append text

How to append text at the end of the file in vim?

To append text at the end of the file we have to use the following.

Press Escape [Esc] to switch to command mode
Press G to move to the last line of the file
Press A to move to the end of the last line and enter into INSERT mode to append text

How to insert an opening line above the current line in vim?

An opening line is simply a blank line between two lines.

To insert an opening line above the current line press O

How to insert an opening line below the current line in vim?

To insert an opening line below the current line press o

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT