Copy multiple files using vim

by Mohan 2013-05-18 16:26:02

<h2> Here are the steps to work with multiple files using vim in linux</h2>

Step 1: Open the terminal.

Step 2: Type the following command in terminal
vi filename1 filename2 filename3

Here filename1 represents a file
filename2 represents a file
filename3 represents a file

Step 3: The vim editor opens filename1 file.

You can switch over the files using :n command
and then hit enter to switch to next file.
and then hit enter to switch to previous file.
->to see the files that are open.
:buffer 1
-> to switch to first file.

Step 4: To copy content from one file to another use the following commands

Open the file from which content has to be copied
:buffer 1

opens first file. use command 'yy' to copy a line from file.
Then type the command
:buffer 2

opens the second file. place the cursor where you want to paste the content and press 'p'.
The copied text will be pasted on the second file.

You must LOGIN to add comments