UNIX – Lesson 012 – vi editor – Copy, Paste and Change Text
Copy Text: yw, yy
- yw yank the current word
- yy yank the current line
- [n]yy yank [n] lines
- y^ yank to the beginning of the line
- y$ yank to the end of the line
- yG yank through the last line
Paste Text: P, p
- P paste contents of the buffer into the text before the cursor
- p paste contents of the buffer back into the text after the cursor
The combination of delete and paste operation allows you to easily move blocks of text.
Change Text: r, R, cw, .
- rcharacter replaces the character at the current cursor position with the named character
- R replaces all characters (goes into overstrike mode) until ESC is pressed
- cw changes the current word
- [n]cw changes next [n] words
- cc changes the current line entirely
- c^ changes to the beginning of the line
- c$ changes from the cursor to the end of the line
- cG changes through the last line of the file
- ~ changes case of character
The dot (.) command is probably one of the handiest commands available in vi.
This allows you to repeat last change operation (this includes deletes too)