Wednesday, June 23, 2010

Unix: Copy, Paste in Vim

Working around with vim.

Vim Cookbook


Copying a block of text from one file to another (Vi Style)

There is more than one way to copy text between files. In this section we use the more triditionally Vi commands. In the next section Copying using visual mode, we perform the same operations using the Visual mode.

To copy a block of text between files execute the commands:

CommandExplaination
1. Edit the file containing the text you want to copy.
2. Go to the top line to be copied.
3.maMark this line as mark "a".
4. Go to the bottom line to be copied
5.y'aYank (y) the text from the current cursor location to the mark "a" ('a)
6.:split second-fileOpen another window containing the second file. (This the file in which the text is to be inserted.)
7. Go to the line where the insert is to occur. The text will be place after this line.
8.pPut the text after the cursor.