copy partial lines in VI
You can do y
Movement, so for 10 characters: y10l
yanks 10 characters from (and including) the current cursor position
I prefer just pressing the v key, then using the cursor keys to move your selection. Then press the y key when you satisfied to yank the selection.
I would guess the most common partial yanks are:
yaw
: yank the word the cursor is currently in2yaw
: yank the word the cursor in currently in and the next (2 words total)ya(
: yank the matched parentheses containing the cursoryf.
: yank from the cursor to the next .
y$
: yank from the cursor to the end of the line
Any movement keys can be used.
Cut and paste:
Position the cursor where you want to begin cutting.
- Press v to select characters (or uppercase V to select whole lines).
- Move the cursor to the end of what you want to cut.
- Press d to cut (or y to copy).
- Move to where you would like to paste.
- Press P to paste before the cursor, or p to paste after.
- Copy and paste is performed with the same steps except for step 4 where you would press y instead of d:
d = delete = cut
y = yank = copy
Resource: vim.wikia.com: Copy, cut and paste