Wednesday, January 28, 2009

Vim Tips: Copy and paste text

Copy:
'Y' or 'yy': copies (yanks) one or more lines.
10Y: copies 10 lines.
yG: copies all lines to the end of the file.
yw: yank text from the current cursor position to the end of the word.
y$: yank text from the current cursor position to the end of the line.

Paste:
P(uppercase): to paste the text contained in the buffer above the current cursor position.
p(lowcase): to paste the text contained in the buffer below the current cursor position.

Insert:
I(uppercase) : insert to the start of the current line.
A(uppercase): append to the end of the current line.
r(lowcase) : overwrite one character. After overwriting the simple character, go back to command mode.
R(lowcase): enter insert mode but replace characters after than inserting.

Entering visual mode:
v(lowcase) : start hightlighting characters.
V(uppercase) : start hightlighting lines.

Moving:
0(zero) : to the beginnning of a line.
$ : to the end of a line.

Editing blocks of text:
(The Vim commands marked with (V) work in visual mode, when you've selected some text).
~ : change the case of characters.
>(V) : shift right.
<(V) : shift left.
y(V) : yank the highlighted text.
d(V) : delete the highlighted text.

No comments: