Vi editor

by RameshKumar 2007-12-01 11:05:00

Bulk delete or copy then paste a block of sentences within a file

1. Move the cursor to the first line of the block of sentences and press mm
2. Move the cursor to the last line of the block of sentences
3. Press d'm to delete the block of sentences from current line where the cursor stop to the line where "m" marker initiated in step 1, OR
4. Press y'm to copy the block of sentences from current line where the cursor stop to the line where "m" marker initiated in step 1, THEN
5. Move the cursor to a position of file where it is intended to paste the copied block of sentences
6. Press p to paste the copied block of sentences.

Bulk copy a block of sentences in file A and paste the copied sentences to file B

1. Move the cursor to the first line of the block of sentences and press mm
2. Move the cursor to the last line of the block of sentences
3. Press "by'm to copy the block of sentences from current line where the cursor stop to the line where "m" marker initiated in step 1
4. Press :e fileB to open another file called fileB for editing

* Use command code :!e fileB instead of :e fileB if there is a need to continue editing fileA after exiting fileB.

5. Move the cursor to a position of file where it is intended to paste the copied block of sentences
6. Press "bp to paste the copied block of sentences from fileA to fileB.

Copy portion of text in a line then paste to elsewhere within a file

1. Move the cursor to the first character of the intended portion of text to be copied and press mm
2. Move the cursor to the last character of the intended portion of text to be copied
3. Press y`m to copy the portion of text from the first character where "m" marker initiated in step 1 to the last character where current cursor stop.
4. Move the cursor to the intended position of the file
5. Press p to paste the copied portion of text.

* To copy portion of text from file A and paste the copied text to file B, use command code "by`m instead of y`m
* Read carefully that y'm function differently from y`m as shown. They are different syntax, indeed!


Tagged in:

2010
like
0
dislike
0
mail
flag

You must LOGIN to add comments