How to Copy and Paste Text in one line With vi or vim in Linux

There is easy way to copy the one line text in linux. Assume that you are editing the configuration file using vi.

1. Go to the line that you want to copy. For example scroll the pointer to line 1.

    1 # SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER    <---- scroll the pointer to line 1,Click shift+y
    2 # Last Modified: 11-26-2005
    3 # Test line three   <--- existing line 3
    

2. Click Shift + y. This will copy the whole line of line 1

3. Scroll the pointer to line 3. Click Shift+ p. This will paste the copied line 1 (whole text in line 1) at line 3 and move down the existing line 3 to line 4. That’s mean, it will append one line.

    1 # SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER
    2 # Last Modified: 11-26-2005
    3 # SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER    <--- scroll the pointer to line 3, Click shift+p
    4 #Test line 3   <--- existing line 3 has moved down to line 4
    

Leave a Reply

Your email address will not be published. Required fields are marked *