OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

Copying Content From One File Into Another

Often while editing multiple files, we will want to copy a portion of one file into another file that we are editing. This is easily done using the usual yank and paste commands we used earlier. We can demonstrate as follows. First, using our two files, switch to buffer 1 (foo.txt) by entering:


:buffer 1

:buffer 1


which should give us this:


The quick brown fox jumped over the lazy dog. It was cool. Line 2

Line 3

Line 4

Line 5

The quick brown fox jumped over the lazy dog. It was cool. Line 2

Line 3

Line 4

Line 5


Next, move the cursor to the first line, and type yy to yank (copy) the line. Switch to the second buffer by entering:


:buffer 2

:buffer 2


The screen will now contain some file listings like this (only a portion is shown here):


total 343700

-rwxr-xr-x 1 root root

-rwxr-xr-x 1 root root

-rwxr-xr-x 1 root root

-rwxr-xr-x 1 root root

-rwxr-xr-x 1 root root

-rwxr-xr-x 1 root root

31316 2015-12-05 08:58 [

8240 2015-12-09 13:39 411toppm

111276 2016-01-31 13:36 a2p

25368 2014-10-06 20:16 a52dec

11532 2015-05-04 17:43 aafire

7292 2015-05-04 17:43 aainfo

total 343700

-rwxr-xr-x 1 root root

-rwxr-xr-x 1 root root

-rwxr-xr-x 1 root root

-rwxr-xr-x 1 root root

-rwxr-xr-x 1 root root

-rwxr-xr-x 1 root root


image

Move the cursor to the first line and paste the line we copied from the preceding file by typing the p command:


total 343700

The quick brown fox jumped over the lazy dog. It was cool.

-rwxr-xr-x 1 root root 31316 2015-12-05 08:58 [

-rwxr-xr-x 1 root root 8240 2015-12-09 13:39 411toppm

-rwxr-xr-x 1 root root 111276 2016-01-31 13:36 a2p

-rwxr-xr-x 1 root root 25368 2014-10-06 20:16 a52dec

-rwxr-xr-x 1 root root 11532 2015-05-04 17:43 aafire

-rwxr-xr-x 1 root root 7292 2015-05-04 17:43 aainfo

total 343700

The quick brown fox jumped over the lazy dog. It was cool.

-rwxr-xr-x 1 root root 31316 2015-12-05 08:58 [

-rwxr-xr-x 1 root root 8240 2015-12-09 13:39 411toppm

-rwxr-xr-x 1 root root 111276 2016-01-31 13:36 a2p

-rwxr-xr-x 1 root root 25368 2014-10-06 20:16 a52dec

-rwxr-xr-x 1 root root 11532 2015-05-04 17:43 aafire

-rwxr-xr-x 1 root root 7292 2015-05-04 17:43 aainfo


Top OS Cloud Computing at OnWorks: